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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With