I am making a game in Cocos2d. I want enemies to spawn on the right and left sides of the screen, and move to a random point on the screen, then repeat. Despite my efforts, I cannot figure it out. This should be relatively easy to answer, it should look like something out of one of Ray Wenderlich’s tutorials. Some code would be nice. Thanks!
Share
This is the code from ray Wanderlich tutorial..
minY–>position at the bottom of the screen
maxY—>position at the top of the screen.
rangeY —> the height of the screen.
actualY—>calculate the random point between bottom of the screen and top of the screen.
target.position –> setting random position for the sprite to move.
actualDuration –> getting random duration.so that the sprite moves in various time delay.
actionMove –> creating Move action.
actionMoveDone —> After completing move action,calling spriteMoveFinished to remove sprites.