【发布时间】:2012-09-14 10:05:32
【问题描述】:
我发现 several post 教如何将 UIBezierPaths 与 CoreAnimation 一起使用。这是因为 CAKeyframeAnimation 对象有一个名为 path 的属性,它的类型是 CGPath,而且 UIBezierPaths 对象也有一个 CGPath 属性。
我想知道如何让 CCSprite 跟随 CGPath 移动。
在 CGPath 中有一个函数 CGPathGetCurrentPoint 可以帮助我获取路径中的当前点,但我找不到“移动到下一个点”之类的东西。
我的伪代码会这样工作:
Create a CCSprite subclass with a UIBezierPaths property
Initialize the UIBezierPaths instance
Allocate the CCSprite subclass in a layer
schedule updates
In update method
Reposition the CCSprite sublcass instance by getting the CGPathGetCurrentPoint to CGPathGetCurrentPoint
Move the path forward by calling "move to next point"
知道这是否可行吗?这是一种有效的方法吗?
【问题讨论】:
标签: cocos2d-iphone sprite uibezierpath ccsprite cgpath