Her iki saniyede bir, ekranımda bulunan bir HUD üzerinde puanı tek tek artıracak olan bir zamanlayıcıyı nasıl oluşturabilirim?SpriteKit - Bir zamanlayıcı oluşturma
@implementation MyScene
{
int counter;
BOOL updateLabel;
SKLabelNode *counterLabel;
}
-(id)initWithSize:(CGSize)size
{
if (self = [super initWithSize:size])
{
counter = 0;
updateLabel = false;
counterLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster"];
counterLabel.name = @"myCounterLabel";
counterLabel.text = @"0";
counterLabel.fontSize = 20;
counterLabel.fontColor = [SKColor yellowColor];
counterLabel.horizontalAlignmentMode = SKLabelHorizontalAlignmentModeCenter;
counterLabel.verticalAlignmentMode = SKLabelVerticalAlignmentModeBottom;
counterLabel.position = CGPointMake(50,50); // change x,y to location you want
counterLabel.zPosition = 900;
[self addChild: counterLabel];
}
}
Neden güncelleştirme (currentTime) yöntemini geçersiz kılmıyorsunuz? "sahne bir görünümde sunulduğu ve duraklatılmadığı sürece çerçeve başına tam olarak bir kez çağrılır" – OhadM