Is it possible to change a CCSprite's position during a move action, like CCMoveBy? I have a subclass of CCSprite that cycles through a bunch of actions, some of which are moves. I check to see if it has gone offscreen, and then attempt to move it directly to the opposite side of the screen. So if it went offscreen left halfway through a move to the left, it would finish the move from the right side of the screen.
But if I use setPosition: it doesn’t seem to work, it just finishes it’s move action.
CCMoveTo(whichCCMoveByis a subclass of) stores the initial position of the object and adds a delta to that stored position at each update, so any other setting of position would be pointless as the next update would put it back on its old path.You can change your code to use two
CCMoveToactions – one taking the object off screen, and another to move it back in from the other side. Alternatively, you can create your own action (take a look at the source code forCCMoveToif you’re unsure how that’s done).