I'm working on a game with finding objects on the screen which has also implemented the parallax effect. For certain reasons I've added my objects as CCMenuItems to the parallax layers
I'd like to know which will be the best practice to handle my objects; also please note that my game is split in several pars (for e.g. he founds 3 objects and then I display a pop-up dialog, the same of other parts). On the HUD layer I should have a list with object name up to 5 (but a part can contain more than 5 objects).
For now I only managed to do it for the first part but I pretty sure that I'm not doing it in the right way...
//I'm adding an object in this way
objecItem = [[CCMenuItemSprite
itemFromNormalSprite:[CCSprite spriteWithSpriteFrameName:@"object.png"]
selectedSprite:[CCSprite spriteWithSpriteFrameName:@"object.png"]
target:self
selector:@selector(removeObject:)] retain];
//Enabled only for ones from part 1
objecItem.isEnabled = YES;
objecItem.tag = kObjectTag;
[objecItem setPosition: ccp(object_X,object_Y)];
[objecItem setAnchorPoint: ccp(0,0)];
objectMenu = [CCMenu menuWithItems:objecItem, nil];
[objectMenu setPosition: ccp(0,0)];
[self addChild:objectMenu z:3 tag:kObjectTag];
//The remove method looks like this:
- (void)removeObject:(id)sender {
CCMenuItemSprite *pointedObjectItem = (CCMenuItemSprite *)sender;
if (pointedObjectItem.isEnabled == YES && pointedObjectItem.isSelected == YES) {
//For the first part my objects are overlapped and I think that just need to know if he removed the bottom one
if (bottomPart1Object.isEnabled == YES && bottomPart1Object.isSelected == YES)
//Enable objects from part 2;
}
}
How should I do for the part 3, an so on?
I'm quite newbie with cocos2d, snipped code would help me a lot ;)