Quote:
Originally Posted by LeopardDevX
Hm..
I dont know how to use the spawn code if a have a UIIMageView named enemy and want a new enemy to pop up every 4. second...
I already have a timer to call a method called spawnE, and the only thing i need is the code to pop up a new enemy...
|
Same as the ball code above, except you don't need the loop if you're only creating one enemy. There's no way to "copy" the existing enemy, that I know of.
Code:
//spawn a new enemy, and add to the array:
UIImage *enemyImage = [UIImage imageNamed:@"enemy.png"];
UIImageView *newEnemy = [[UIImageView alloc] initWithImage: enemyImage];
//set X and Y of the new imageView
newEnemy.center = CGPointMake(150, 150);
//add to array
[enemies addObject:newEnemy];
//add to the view, so it gets displayed.
[self.view addSubview: newEnemy];