Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

joeysefika

macrumors newbie
Original poster
Sep 26, 2009
5
0
Ok, so I've made a really basic 2D app that has a space ship at the bottom that moves around horizontally by using your finger. The objective of the game is to dodge falling missiles/ asteroids etc.
Code:
//HERE IS THE SPRITES ANIMATION AND SPAWN INFO
	//*
	//*
	SpaceJunkImages = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"flash1.png"], [UIImage imageNamed:@"flash3.png"], [UIImage imageNamed:@"flash4.png"], [UIImage imageNamed:@"flash5.png"], [UIImage imageNamed:@"flash2.png"], nil];
	
	SpaceJunk = [[UIImageView alloc] initWithFrame: CGRectMake (100, 220, 30, 30)];
	SpaceJunk.animationDuration = 0.5;
	SpaceJunk.contentMode = UIViewContentModeBottomLeft;
	SpaceJunk.animationImages = SpaceJunkImages;
	[SpaceJunk startAnimating];
	
	[self.view addSubview:SpaceJunk];
	//*
	//*

So my objective is to make it so the object 'SpaceJunk' is drawn off screen and randomly generated over and over again at different points on the X axis.

Thanks for any feedback, Joe
 
probably want something like
int randomX = arc4random() % 100 + 1;
so its a random number between 1 and 100

then when you do your CGRect just insert that x value so they have a random x position
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.