iphoneobjective-ccocos2d-iphonecocos3d3d-engine

How to move a node in cocos2d and cocos3d


I have a node. In this particular case, it's a CCLayer, but I'm looking for a general solution. My node is centered at point1 (let's say { 100, 100 }). I'd like it to move to point1 (say { 200, 200 }) over the course of 0.5 seconds.

Really simple stuff, right? But I'm just not finding the docs/tutorials I need to do it.

Hints?

Thanks!

Extra credit: same question with a CC3Node, if the answer is different. :)


Solution

  • You can move anything inherits CCNode using runAction: [CCMoveTo actionWithDuration: 0.5 position:ccp(x,y)]

    http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:actions