#include #include namespace farmlands { namespace model { Transform::Transform(GameObject* obj) : x(0), y(0), scaleX(1), scaleY(1), gameObject(obj) { } float Transform::globalX() const { return (gameObject->parent()) ? x + gameObject->parent()->transform.globalX() : x; } float Transform::globalY() const { return (gameObject->parent()) ? y + gameObject->parent()->transform.globalY() : y; } void Transform::setGlobalX(float gx) { x = (gameObject->parent()) ? gx - gameObject->parent()->transform.globalX() : gx; } void Transform::setGlobalY(float gy) { y = (gameObject->parent()) ? gy - gameObject->parent()->transform.globalY() : gy; } float Transform::globalScaleX() const { return (gameObject->parent()) ? scaleX * gameObject->parent()->transform.globalScaleX() : scaleX; } float Transform::globalScaleY() const { return (gameObject->parent()) ? scaleY * gameObject->parent()->transform.globalScaleY() : scaleY; } void Transform::setGlobalScaleX(float gscaleX) { scaleX = (gameObject->parent()) ? gscaleX / gameObject->parent()->transform.globalScaleX() : gscaleX; } void Transform::setGlobalScaleY(float gscaleY) { scaleY = (gameObject->parent()) ? gscaleY / gameObject->parent()->transform.globalScaleY() : gscaleY; } } } /* namespace farmlands */