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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 12-17-2009, 02:12 PM   #9 (permalink)
BrianSlick
Emphasizing Fundamentals
 
BrianSlick's Avatar
 
Join Date: Jul 2009
Location: NoVA / DC Area
Age: 36
Posts: 7,978
BrianSlick has a spectacular aura about
Default

Quote:
Originally Posted by benoitr007 View Post
Ok, I get it. I have another question:

I have this huge array that contains all the different layers of enemies and objects in the game. Each layer of enemies/objects is an array containing specific objects. Right now I'm initializing like that, is that fine?

Code:
objectsArrays = [[NSMutableArray alloc] init];

enemiesLayer1 = [[NSMutableArray alloc] init];
[objectsArrays addObject:enemiesLayer1];
[enemiesLayer1 release];

enemiesLayer2 = [[NSMutableArray alloc] init];
[objectsArrays addObject:enemiesLayer2];
[enemiesLayer2 release];

objectsLayer1 = [[NSMutableArray alloc] init];
[objectsArrays addObject:objectsLayer1];
[objectsLayer1 release];

objectsLayer2 = [[NSMutableArray alloc] init];
[objectsArrays addObject:objectsLayer2];
[objectsLayer2 release];
I would probably make a @property for objectsArrays and do the stuff previously mentioned, but otherwise it's fine.

Quote:
Originally Posted by benoitr007 View Post
I'm doing it like that to then parse the objectsArrays array to draw every object in order, like this:

Code:
NSMutableArray *currentArray;
for (int i = 0; i < [objectsArrays count]; i ++) {
	currentArray = [objectsArrays objectAtIndex:i];
	for (int n = [currentArray count] - 1; n >= 0; n -= 1) {
		FallingObject *currentObject = [currentArray objectAtIndex:n];
		[currentObject render];
	}
}
Looks fine at quick glance. Nothing jumping out at me. There is a cool NSArray method that might simply that a bit: makeObjectsPerformSelector:
__________________
BriTer Ideas LLC - Code review, consulting, development. Available for hire.

SlickShopper 2 | Free NSLog utility | Leave a PayPal donation.

Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | Guide To Troubleshooting | Model Object Overview

Do you sit at a desk all day? Walk instead! Follow along with my treadmill desk adventures.
BrianSlick is online now   Reply With Quote
 

» Advertisements
» Stats
Members: 175,415
Threads: 94,015
Posts: 402,527
Top Poster: BrianSlick (7,978)
Welcome to our newest member, deannme48
Powered by vBadvanced CMPS v3.1.0

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