Reputation: 627
I'm making a game in Swift and I want the sprites to move faster as the time passes.
I have a variable that increases in every second (It works with an NSTimer
). I want to replace the duraton with this variable, in this line of code:
let action = SKAction.moveToY(120, duration: 3)
But I can't because the duration must be of type NSTimeInterval
.
How can I transform my variable (which is Int) to NSTime Interval so it can work properly?
Upvotes: 2
Views: 9279
Reputation: 38142
NSTimeInterval is defined as:
typealias NSTimeInterval = Double
So, technically, you can define your interval and assign direct integers:
var interval: NSTimeInterval = 3
Upvotes: 6