Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 03-27-2009, 01: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: 2,575
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];
__________________
smasher is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,301
Threads: 39,104
Posts: 171,438
Top Poster: smasher (2,575)
Welcome to our newest member, alekssebasstrs
Powered by vBadvanced CMPS v3.1.0

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