我怎样才能通过像 Cocos2D 这样的 SpriteKit 倾斜/剪切精灵? [英] How could I skew/shear a sprite via SpriteKit like Cocos2D?
问题描述
在Cocos2D-x中,CCNode类提供了skewX"&skewY"让我对精灵进行一些扭曲,但是,我在 SpriteKit 的 SKNode 中找不到类似的映射.
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.
我的游戏使用 Flash 来移植骨骼动画,其中精灵的定位、缩放、旋转和剪切配置将被分解为游戏引擎的消化系统.除了剪切之外,所有其他配置都有解决方案需要在 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.
推荐答案
不,你不能.
SKNode 没有 skew* 属性.SKShader 只允许使用片段着色器.这意味着您可以随意更改每个像素的颜色,但不能更改精灵的形状.
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.
所以我推荐你使用 Cocos2d-Swift, Cocos2d-x 等而不是SpriteKit.
So I recommend you to use Cocos2d-Swift, Cocos2d-x or so on instead of SpriteKit.
另一个选项是 UIView.您可以通过 Adobe Flash 使用矩阵到 UIViewCALayer 变换.
Another option is UIView. You can use the matrix from Adobe Flash to UIView via CALayer transform.
这篇关于我怎样才能通过像 Cocos2D 这样的 SpriteKit 倾斜/剪切精灵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!