开发者

Move sprite up while tapping/holding in Cocos2D for iPhone

I was wondering how to have it in Cocos2D to make a sprite move up, while the user's finger is being held on the screen. I have a mechanism in place that does so, but only moves the sprite once.

Is it possible to have the sprite move up while the finger is holding on the screen?

Also, even though it's not necessary, if you could make it so when the user isn't holding on the screen, the sprite goes down开发者_运维技巧.

Thanks, I think that a physics engine such as Box2D of Chipmunk is necessary, but I'm not sure how to do this.

-Soule


I have a not so perfect answer: set up a repeatable timer with a short interval, at most 0.1 second, then fire the timer in ccTouchBegan, invalid the timer in ccTouchEnded. Everytime the timer ticks, move the sprite a short distance. the shorter the interval is, the smoother the move will be.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜