I’ve been following this code snippet from Ray Wenderlich’s tutorials (http://codeviewer.org/view/code:1d8b). I’m trying to do almost the same thing, except I’m using a spritesheet (batchnode), and I want the targets/enemies to spawn from the right side of the screen (at any height), and move to the left side (at the same height). Here is my code. (http://codeviewer.org/view/code:1d8c).
Extra info – “moles” are my targets/enemies. Commented out code (//) beside the first few lines are just my notes.
EDIT – Look at my comment on mjvotaw’s answer.
If you want to place your mole sprite in a random spot along the right side, you should be able to just do:
That sets the mole at the far right edge, at a random spot along the y axis.
Then, instead of actionMove using CCMoveTo, you can just use CCMoveBy, setting the position to ccp(-winSize.width, 0).
If this isn’t what you’re looking for, perhaps you should rethink how to ask your question.