Cocos2d两个精灵之间的碰撞可防止图像跳跃/移位

时间:2014-06-17 20:42:34

标签: ios objective-c cocos2d-iphone cocos2d-iphone-3

当我的角色精灵与怪物精灵发生碰撞时,我遇到了问题,怪物的变化与角色精灵一样。通过移位我的意思是,稍微旋转角色,并稍微反弹怪物角色。我怎么做才能让精灵在碰撞时实际转移位置?

以下是我目前使用的代码

- (BOOL)ccPhysicsCollisionBegin:(CCPhysicsCollisionPair *)pair collisionPlayer:(CCNode *)user collisionMonster:(CCNode *)monster
{

        [monster stopAllActions];

        [[OALSimpleAudio sharedInstance] playEffect:@"Zombie.mp3" volume:10.0f pitch:1.0f pan:0 loop:NO];

        CCActionRotateTo* actionSpin = [CCActionRotateBy actionWithDuration:0 angle:90];
        [monster runAction:actionSpin];

        CCActionDelay *corpseDecayDelay = [CCActionDelay actionWithDuration:0.8];
        CCActionFadeOut *corpseFade = [CCActionFadeOut actionWithDuration:0.5];

        CCActionRemove *removeElement = [CCActionRemove action];
        CCActionSequence* monsterDeathSequence = [CCActionSequence actions:corpseDecayDelay,corpseFade, removeElement, nil];
        [monster runAction:monsterDeathSequence];


        return YES;
}

0 个答案:

没有答案