I'm trying to put a countDown on my application. I'm using a SKLabelNode. This is my code :
class PlayScene: SKScene {
var startCount = true
var setTime = 0
var myTime = 0
var printTime = SKLabelNode(fontNamed: "arial")
override func didMoveToView(view: SKView!) {
self.backgroundColor = UIColor(hex: 0xD64541)
self.printTime.text = NSString(format: "%i", self.myTime)
self.addChild(self.printTime)
}
override func update(currentTime: NSTimeInterval) {
if self.startCount == true {
self.setTime = Int(currentTime)
self.startCount = false
}
self.myTime = Int(currentTime) - self.setTime
}
}
I had no problem to compile it but it's crashing at the execution... I think that's coming from my convertion in string..
Thank you
float timeforFunction;
int numberoftime;
int __totalscore;
timeforFunction=1.5f;
numberoftime=10;
SKAction *updateTime= [SKAction sequence:@[
[SKAction waitForDuration: timeforFunction],
[SKAction performSelector:@selector(updatescore)
onTarget:self]
]];
[self runAction:[SKAction repeatAction:updateTime count: numberoftime] withKey:@"zorbTime"];
-(void) updatescore
{
__totalscore+=1;
_GamescoreText.text = [NSString stringWithFormat:@“%i”, __totalscore];
}
if you wanna repeat this action forever just change to
[self runAction:[SKAction repeatAction:updateTime count: numberoftime] withKey:@"zorbTime"];