Quote:
Originally Posted by kdp8791
Thats what I am trying to do as well. I only want one image falling from the top at a time and when that image rolls off the screen another falls. But for some reason, when the view loads the images just appear on the screen as if they were placed there from Interface Builder in one solid location. No movement nothing. I have setup the NSTimer as well, so I am not sure what is wrong and why it's not moving.
|
If you only want one meteor, you should not create the array of meteors; you should just create one meteor "myRock". I also changed it to "y = 0" - if you're only making one rock it makes sense to put it at the top of the screen, not far off the top like the other code.
Code:
-(void)createMeteors{
UIImage *meteorImage = [UIImage imageNamed:@"flake.png"];
myRock= [[UIImageView alloc] initWithImage: meteorImage];
//pick a position *above* the top of the screen
int x = arc4random()%320;
int y = 0; // place at top of the screen
myRock.center = CGPointMake (x,y);
[self.view addSubview: myRock]; //adds meteors as subviews
[myRockrelease];
}