Search code examples
cocos2d-iphonesprite-kit

How could I skew/shear a sprite via SpriteKit like Cocos2D?


In Cocos2D-x, CCNode class provides "skewX" & "skewY" to let me do some distortion of the sprite, however, I fail to find similar mapping in SKNode of SpriteKit.

My game uses Flash to port skeleton animations, in which the configs of positioning, scaling, rotation and shearing of sprites would be decomposed into game-engine's digestive. Except shearing, all other configs do have solutions to be done in SpriteKit.


Solution

  • No you can't.

    SKNode doesn't have skew* properties. And SKShader allows to use only fragment shader. It means you can change the color of each pixel whatever you want, but you can't change the shape of a sprite.

    So I recommend you to use Cocos2d-Swift, Cocos2d-x or so on instead of SpriteKit.

    Another option is UIView. You can use the matrix from Adobe Flash to UIView via CALayer transform.