0
我如何編碼碰撞計數?現在,它可以顯示爲分數:d計數碰撞Cocos2d 3.0
這是我撞的代碼
- (BOOL)ccPhysicsCollisionBegin:(CCPhysicsCollisionPair *)pair monsterCollision:(CCNode *)monster projectileCollision:(CCNode *)projectile {
//Creating another sprite on the position the monster one was.
CCSprite *explosion = [CCSprite spriteWithImageNamed:@"explosion.png"];
explosion.position = monster.position;
[self addChild:explosion];
CCActionDelay *delay = [CCActionDelay actionWithDuration:.0f];
CCActionFadeOut *fade = [CCActionFadeOut actionWithDuration:.4f];
[explosion runAction:[CCActionSequence actionWithArray:@[delay,fade]]];
[monster removeFromParent];
[projectile removeFromParent];
return YES;
}
,我會添加什麼來算怪物的碰撞?
謝謝:)
新代碼
CCLabelTTF *scorelabel = [CCLabelTTF labelWithString:[NSString stringWithFormat:@"score: %d",score] fontName:@"Verdana-Bold" fontSize:18.0f];
scorelabel.positionType = CCPositionTypeNormalized;
scorelabel.color = [CCColor blackColor];
scorelabel.position = ccp(0.85f, 0.95f); // Top Right of screen
[self addChild:scorelabel];
好吧,所以我得到了所有的工作,但現在我試圖顯示它和標籤,我不會更新。我更新了上面的代碼,並感謝您的所有建議:D – Crazycriss
如果這是其他問題,我會感謝您的正確答案檢查,然後您可以再次詢問其他主題,我可以再次幫助您。謝謝 –