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-26-2009, 05:45 PM   #10 (permalink)
LeopardDevX
iPhone Developer
 
Join Date: Mar 2009
Posts: 222
Smile but...

Quote:
Originally Posted by smasher View Post
Here's code to do something similar - it will put 10 copies of the same image on the screen, and put them in an array so you can get to them later. This code would work in viewDidLoad of a viewController, for example.

Code:
	//declare the array in the .h file if you want to accessible
	//from all methods.
	NSMutableArray *arrayOfBalls

	//create the array
	arrayOfBalls = [[NSMutableArray alloc] init];

	UIImage *ballImage = [UIImage imageNamed:@"ball.png"];

	for (int i=0; i<10 ; i++){
		
		UIImageView *newBall = [[UIImageView alloc] initWithImage: ballImage];

		//set X and Y of the new imageView
		newBall.center = CGPointMake(100 + i*10, 100+ i*10);
		
		//add to array
		[arrayOfBalls addObject:newBall];
		
		//add to the view, so it gets displayed.
		[self.view addSubview: newBall];
	}



Not sure why - the syntax is fine. You might get a warning if you already have a variable called myBlock; when you make two variables with the same name in different scopes, the local one hides the gobal one.


,But if i already have a array of enemies do i need another one?

My array of enemies contains uiimageview of a enemy that i added to the array when the game starts and i have a timer to move the enemy, a timer to call spawnenemy method and a timer to keep score...

And i need to spawn enemies randomly in the x axe (i only need one type of enemy that i have added to the array)... how can this be done??
And how can i increase a timers intervals in a void?? that is being called some time.....



Thanks for all current replies and future...
__________________
Thank You.

Last edited by LeopardDevX; 03-26-2009 at 05:48 PM.
LeopardDevX is offline   Reply With Quote
 

» Advertisements
» Online Users: 704
26 members and 678 guests
AdamL, ADY, AppAnnex, headkaze, jbro, joeallenpro, linkmx, Mah6447, marto1914, mongoose250, muhimranss, NetGuru, Oral B, pinky, RileyE, sandihf, Shmoopi, simontheu, Speed, Sunny46, Svaths, syver, vikinara, viniciusdamone, vonkal, zambono
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,732
Threads: 89,189
Posts: 380,525
Top Poster: BrianSlick (7,128)
Welcome to our newest member, sandihf
Powered by vBadvanced CMPS v3.1.0

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