objective c - remove sprites with animation, different z order -
objective c - remove sprites with animation, different z order -
how remove sprites on top of each 1 different z order?
the code i'm using is:
- (void)removeselectedsprite:(cgpoint)touchlocation { ccsprite * newsprite = nil; (ccsprite *sprite in selectedspritesarray) { if (cgrectcontainspoint(sprite.boundingbox, touchlocation)) { newsprite = sprite; break; } } if (newsprite) { ccsprite *fixedsprite = [ccsprite spritewithspriteframename:@"animation_01.png"]; fixedsprite.position = ccp(newsprite.contentsize.width/2,newsprite.contentsize.height/2); [newsprite addchild:fixedsprite]; nsmutablearray *animframes = [nsmutablearray array]; for(int = 1; <= 5; ++i) { [animframes addobject: [[ccspriteframecache sharedspriteframecache] spriteframebyname: [nsstring stringwithformat:@"animation_%02d.png", i]]]; } ccanimation *anim = [ccanimation animationwithframes:animframes delay:0.05f]; ccactioninterval *animaction = [ccanimate actionwithanimation:anim restoreoriginalframe:no]; id seq = [ccsequence actions: animaction, [cccallfunc actionwithtarget:fixedsprite selector:@selector(removefromparentandcleanup:)], [cccallfunc actionwithtarget:newsprite selector:@selector(removefromparentandcleanup:)], nil]; [fixedsprite runaction:seq]; } } - (bool)cctouchbegan:(uitouch *)touch withevent:(uievent *)event { cgpoint touchlocation = [self converttouchtonodespace:touch]; [self removeselectedsprite:touchlocation]; homecoming true; } why not working sprites on top of each 1 (having different z order)?
don't know if there improve way what's coming in mind check layer childrens , z-order , remove based on z-order.
objective-c cocos2d-iphone ccsprite
Comments
Post a Comment