public CGAffineTransform nodeToParentTransform()
{
if ( _isTransformDirty ) {
// Translate values
float x = _position.x;
float y = _position.y;
if ( _ignoreAnchorPointForPosition ) {
x += _anchorPointInPixels.x;
y += _anchorPointInPixels.y;
}
// Rotation values
// Change rotation code to handle X and Y
// If we skew with the exact same value for both x and y then we're simply just rotating
float cx = 1, sx = 0, cy = 1, sy = 0;
if(!FloatUtils.EQ(_rotation, 0)) {
float radiansX = -ccUtils.CC_DEGREES_TO_RADIANS(_rotation);
float radiansY = -ccUtils.CC_DEGREES_TO_RADIANS(_rotation);
cx = Mathf.Cos(radiansX);
sx = Mathf.Sin(radiansX);
cy = Mathf.Cos(radiansY);
sy = Mathf.Sin(radiansY);
}
// optimization:
// inline anchor point calculation if skew is not needed
// Adjusted transform calculation for rotational skew
if( _anchorPointInPixels != Vector2.zero ) {
x += cy * -_anchorPointInPixels.x * _scaleX + -sx * -_anchorPointInPixels.y * _scaleY;
y += sy * -_anchorPointInPixels.x * _scaleX + cx * -_anchorPointInPixels.y * _scaleY;
}
// Build Transform Matrix
// Adjusted transfor m calculation for rotational skew
_transform = CGAffineTransform.Make( cy * _scaleX, sy * _scaleX,
-sx * _scaleY, cx * _scaleY,
x, y );
_isTransformDirty = false;
}
return _transform;
}
public CGAffineTransform parentToNodeTransform()