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-26-2009, 04:45 PM   #10 (permalink)
LeopardDevX
iPhone Developer
 
Join Date: Mar 2009
Posts: 220
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 04:48 PM.
LeopardDevX is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,356
Threads: 39,149
Posts: 171,628
Top Poster: smasher (2,577)
Welcome to our newest member, Jakison
Powered by vBadvanced CMPS v3.1.0

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