如何通过SpriteKit(如Cocos2D)使Sprite倾斜/剪切? [英] How could I skew/shear a sprite via SpriteKit like Cocos2D?

查看:107
本文介绍了如何通过SpriteKit(如Cocos2D)使Sprite倾斜/剪切?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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不具有偏斜*属性。并且 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到UIView的矩阵CALayer变换

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

这篇关于如何通过SpriteKit(如Cocos2D)使Sprite倾斜/剪切?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆