Cocos2D - NSMutableArray not accessible in ccTouchBegan? -
first, let's clear on 2 things. english terrible , i'm pretty new in cocos2d. sorry , sorry again. :d question.
i have declared these in .m (its ccscene):
//a mutable array global class nsmutablearray *arrayboutons; //i use array : lettrebleue *lettre1 = nil; lettre1 = [lettrebleue construireobjlettre]; lettre1.position = ccp(80,370); [self addchild:lettre1]; [arrayboutons addobject:lettre1]; //the method register touch -(void) registerwithtouchdispatcher { [[cctouchdispatcher shareddispatcher] addtargeteddelegate:self priority:kccmenutouchpriority swallowstouches:no]; } // classic touchbegan in im trying access value valeur -(bool) cctouchbegan:(uitouch *)touch withevent:(uievent *)event // test! nslog(@"debut test cctouchbegan4"); int cptlettres = 0; { lettrebleue *unboutontest=[arrayboutons objectatindex: cptlettres]; nslog(unboutontest.valeur); cptlettres = cptlettres+1; } while (cptlettres < 16); the problem arrayboutons doesn't seem keep data in nsmutablearray.
have initialized nsmutablearray, perhaps in init method? need call like:
arrayboutons = [[nsmutablearray alloc] init]; then, need release in dealloc method:
[arrayboutons release];
Comments
Post a Comment