quelqu'un peut-il m'aider à enlever la forme et le corps après un délai de rappel de collision. En utilisant cpSpaceAddPostStepCallback (sapce, (cpPostStepFunc) postStepRemove, blockShape, NULL);comment enlever la forme et le corps après un délai de rappel de collision (cocos2d-tamia)
En utilisant cpSpaceAddPostStepCallback (sapce, (cpPostStepFunc) postStepRemove, blockShape, NULL); Je pouvais retirer la forme en toute sécurité. Mais j'ai besoin d'un peu de temps avant d'appeler la fonction. Je joue une animation une fois la collision détectée. À la fin du code, je dois enlever la forme. Quelqu'un peut-il s'il vous plaît aidez-moi avec un exemple de code. Le code que j'ai écrit est le suivant.
int collisionSapusBlock(cpArbiter *arb, struct cpSpace *sapce, void *data)
{
cpShape *sapusShape, *blockShape;
cpArbiterGetShapes(arb, &sapusShape, &blockShape);
cpBody *BlockBody = blockShape->body;
cpBody *sapusBody = sapusShape->body;
CCNode *parent = (CCNode*)data;
if (cpvlength(sapusBody->v) > 45)
{
NSLog(@"Collision2 called %f",cpvlength(sapusBody->v));
CCSprite *sprite = blockShape->data;
[parent removeChild:sprite cleanup:YES];
///////
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"Block2.plist"];
CCSpriteBatchNode *sheet1 = [CCSpriteBatchNode batchNodeWithFile:@"Block2.png" capacity:2];
[parent addChild:sheet1];
CCSpriteFrameCache *cache = [CCSpriteFrameCache sharedSpriteFrameCache];
CCSprite *sapusSprite1 = [[CCSprite alloc] initWithSpriteFrameName:@"Block2001.png"];
CCAnimation *sapusAnim = [[CCAnimation alloc] initWithName:@"select" delay:0.15f];
[sapusAnim addFrame:[cache spriteFrameByName:@"Block2001.png"]];
[sapusAnim addFrame:[cache spriteFrameByName:@"Block2002.png"]];
[sapusAnim addFrame:[cache spriteFrameByName:@"Block2003.png"]];
[sapusAnim addFrame:[cache spriteFrameByName:@"Block2004.png"]];
[sapusAnim addFrame:[cache spriteFrameByName:@"Block2005.png"]];
[sapusAnim addFrame:[cache spriteFrameByName:@"Block2006.png"]];
[sapusSprite1 addAnimation: sapusAnim];
[sheet1 addChild:sapusSprite1];
CCAnimate *animate = [CCAnimate actionWithAnimation: sapusAnim restoreOriginalFrame:NO];
[sapusSprite1 runAction:animate];
blockShape->data = sapusSprite1;
/////here after playing the animation i need to delete the blockShape. Help plzzz
}
return 1;
}
Quelqu'un peut-il s'il vous plaît aidez-moi avec un exemple de code. Merci