I'm currently making a game. I have an UIImageView
that scrolls from right to left and once it leaves the ViewController
the image resets on the right and scrolls left again, this currently set to displays "image1" I would like to change it to display a different image randomly from a set of 5 each time it resets to the right.
Here is my Method:
- (void)PlacePipe{
RandomTopPipePosition = arc4random() %350;
RandomTopPipePosition = RandomTopPipePosition - 228;
RandomBottomPipePosition = RandomTopPipePosition + 660;
PipeTop.center = CGPointMake(340-10, RandomTopPipePosition);
randomImagebottom.center = CGPointMake(340-10, RandomBottomPipePosition);
}
The name of the images I want to randomly add into this UIImageView
are -toppipestyleone.png, toppipestyletwo.png, toppipestylethree.png, toppipestylefour.png, toppipestylefive.png".
I'm not sure at the best route to doing this, I looked at doing it with an array but I'm not sure how to set up an array or even call images randomly.