Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 03-27-2009, 02:51 PM   #15 (permalink)
smasher
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Quote:
Originally Posted by LeopardDevX View Post
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];
__________________

Free Games!
smasher is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,744
Threads: 89,200
Posts: 380,559
Top Poster: BrianSlick (7,129)
Welcome to our newest member, Dani77
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:59 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.