Post

Replies

Boosts

Views

Activity

Arrow key causes delta jump in spritekit.
Hello, I have a problem where my macOS (Sequoia) Spritekit game spikes delta during the first press of an arrow key. I've test this with a small program, code below: // // GameScene.swift import SpriteKit import GameplayKit class GameScene: SKScene { var lastTime: TimeInterval = 0 override func keyDown(with event: NSEvent) { print("---------------> delta keyDown: \(event.characters!) keyCode: \(event.keyCode)") } override func update(_ currentTime: TimeInterval) { // Called before each frame is rendered print("update begins") let dt: CGFloat if lastTime > 0 { dt = (CGFloat(currentTime - lastTime)) } else { dt = 1.0 / 60.0 } if dt > (1/30) { print("************************************ delta spike ", dt) } lastTime = currentTime print("dt: ", dt) print("update ends") } } Example output: update begins ************************************ delta spike 0.03381687504588626 dt: 0.03381687504588626 update ends update begins dt: 0.016670208307914436 update ends As you can see, when I press left arrow key in this case I get a big delta spike. There's no spike with further presses of the arrow key. Other keys, such as the common W A S D controls for games, do not cause this delta spike.
1
0
113
14h
Arrow key causes delta jump in spritekit.
Hello, I have a problem where my macOS (Sequoia) Spritekit game spikes delta during the first press of an arrow key. I've test this with a small program, code below: // // GameScene.swift import SpriteKit import GameplayKit class GameScene: SKScene { var lastTime: TimeInterval = 0 override func keyDown(with event: NSEvent) { print("---------------> delta keyDown: \(event.characters!) keyCode: \(event.keyCode)") } override func update(_ currentTime: TimeInterval) { // Called before each frame is rendered print("update begins") let dt: CGFloat if lastTime > 0 { dt = (CGFloat(currentTime - lastTime)) } else { dt = 1.0 / 60.0 } if dt > (1/30) { print("************************************ delta spike ", dt) } lastTime = currentTime print("dt: ", dt) print("update ends") } } Example output: update begins ************************************ delta spike 0.03381687504588626 dt: 0.03381687504588626 update ends update begins dt: 0.016670208307914436 update ends As you can see, when I press left arrow key in this case I get a big delta spike. There's no spike with further presses of the arrow key. Other keys, such as the common W A S D controls for games, do not cause this delta spike.
Replies
1
Boosts
0
Views
113
Activity
14h
Request for basic GCVirtualController example code
Hello, Could someone post code that shows how to implement GCVirtualController to move a box around the screen? I've been poking around with GCVirtualController and gotten as far as having the D-pad and A B buttons appear on the display. But how do I make it do anything?
Replies
1
Boosts
0
Views
263
Activity
Apr ’25