Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CCMoveBy in cocos2d-iphone

hello everyone i use CCMoveBy for keeping a sprite going

if (abs(dff.x) > abs(dff.y)) {
    id action = [CCMoveBy actionWithDuration:1 position:ccp(10,10)];
    [sprite runAction:[CCRepeatForever actionWithAction:action]];
}
else {
    id action = [CCMoveBy actionWithDuration:1 position:ccp(5,5)];
    [sprite runAction:[CCRepeatForever actionWithAction:action]];
}

if i push the sprite left/right,it will go to left/right,but now when i push it,it will go to the diagonal direction,not left or right or up or down,so what's the right is?thanks

like image 713
mark ma Avatar asked Nov 22 '25 16:11

mark ma


1 Answers

Are you saying you want to just move on one axis? Then in that case you need to keep one of the values in ccp() at 0.

like image 92
Adam Ashwal Avatar answered Nov 24 '25 08:11

Adam Ashwal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!