Return to Snippet

Revision: 38898
at January 10, 2011 03:06 by solgems


Updated Code
for (int i = 0; i < 9; i++ ) {
//create a slot object with a label
//add the object to the slots array

//sprite
	[slots addObject: [[[Slot alloc] initWithSprite:[CCSprite spriteWithFile:@"hole.png"]
		withPos_x:count%3*cellWidth+offset_x
		withPos_y:count/3*cellHeight+offset_y
		isOccupied:NO] autorelease]];

//add the sprite to the layer
	[self addChild: ((Slot*) [slots objectAtIndex:i]).sprite];

	count++;
}

Revision: 38897
at January 10, 2011 01:35 by solgems


Initial Code
for (int i = 0; i < 9; i++ ) {
			//create a slot object with a label
			//add the object to the slots array
			
			//sprite
			[slots addObject: [[[Slot alloc] initWithSprite:[CCSprite spriteWithFile:@"hole.png"]
												  withPos_x:count%3*cellWidth+offset_x
												  withPos_y:count/3*cellHeight+offset_y
												 isOccupied:NO] autorelease]];
			 
			 //add the sprite to the layer
			 [self addChild: ((Slot*) [slots objectAtIndex:i]).sprite];
			
			count++;
		}

Initial URL

                                

Initial Description

                                

Initial Title
initialising and populating an array of Sprites

Initial Tags

                                

Initial Language
Objective C