The following code sets the starting position of the target
int minY = target.contentSize.width/2; int maxY = winSize.width - target.contentSize.width/2; int rangeY = maxY - minY; int actualY = (arc4random() % rangeY) + minY; target.position = ccp(winSize.width + (target.contentSize.width/2), actualY);
This currently randomizes the position of y by setting the variable actualY to a randomized number within the range. To change it so that the y position is always at the bottom of the screen, you need to change the current variable.
int actualY = target.contentSize.height/2;
This should put the target at the bottom of the screen at the beginning. Please note that since I have not made any changes to x paramater, it will always be displayed in the lower right corner. I am sure you can understand how to change the x parameter!
As for the change in direction of movement, which is performed in the next line.
id actionMove = [CCMoveTo actionWithDuration:actualDuration position:ccp(-target.contentSize.width/2, actualY)];
This creates what Cocos2D triggers the action. In particular, this is moving the sprite to the specified position. This position is set inside this function call.
If you try:
id actionMove = [CCMoveTo actionWithDuration:actualDuration position:ccp(-target.contentSize.width/2, winSize.height)];
he must begin to move up, because the goal of the movement is now higher, where it begins. Please note that with this function call, its leftward movement will continue because I did not define another target in the x direction - I think you can figure out how to make it stop based on the rest of this!
Good luck, hope this helps!