In my game I want to call a function every few seconds that creates random objects from an array. Currently I'm moving this objects by SKAction like this:
func createRandmoObject() {
let random = arc4random_uniform(4)
randomObject = randomObjects[random]
randomObject.runAction(SKAction.moveTo(CGPoint(x: randomObject.position.x, y: 0 - randomObject.size.height), duration: 3))
addChild(randomObject)
}
and when the object hits the player it gets removed, then the function gets called again. The problem with this method is I found that the motion of the object isn't always smooth, when the framerate drops for some reason, stutterness occurs. Now I know how to calculate delta time in the update method, but I'm not sure how to apply it to an object when that object keeps changing and not always on the screen, and there are some other objects like it(let's think of them as enemies, and there are another function that creates another enemy) So how can I make those random objects move according to deltatime instead of SKAction?
Aucun commentaire:
Enregistrer un commentaire