0
當計數達到零時,我試圖進入新場景。我有計數工作下降(3,2,1,0),但我想現場改變在0當計數達到0時更改場景Cocos2d 3.0
我將如何能夠實現這一目標?
代碼控制是放置在現場的計數標籤(去是我使用的得分INT)
gone=3;
gonelabel = [CCLabelTTF labelWithString:[NSString stringWithFormat:@"Left: %d",gone] fontName:@"a2203.ttf" fontSize:18.0f];
gonelabel.positionType = CCPositionTypeNormalized;
gonelabel.color = [CCColor blackColor];
gonelabel.position = ccp(0.15f, 0.95f); // Top Right of screen
[self addChild:gonelabel];
代碼計數的碰撞
- (BOOL)ccPhysicsCollisionBegin:(CCPhysicsCollisionPair *)pair monsterCollision:(CCNode *)monster barrierCollision:(CCNode *)barrier {
[monster removeFromParent];
gone--;
[gonelabel setString:[NSString stringWithFormat:@"Left: %d",gone]];
return YES;
}
謝謝你的任何忠告:d
工作完美無瑕,謝謝 – Crazycriss