playground don't move camera when textinput has focus
This commit is contained in:
@@ -64,17 +64,19 @@
|
|||||||
// Control the UI camera with the arrow keys, and the playground camera with wasd:
|
// Control the UI camera with the arrow keys, and the playground camera with wasd:
|
||||||
(var KEYBOARD_SCROLL_SPEED 200)
|
(var KEYBOARD_SCROLL_SPEED 200)
|
||||||
(method cameraKeyControl [:FlxCamera camera :Void->Bool leftKey :Void->Bool rightKey :Void->Bool upKey :Void->Bool downKey]
|
(method cameraKeyControl [:FlxCamera camera :Void->Bool leftKey :Void->Bool rightKey :Void->Bool upKey :Void->Bool downKey]
|
||||||
(let [scrollPerSec (/ KEYBOARD_SCROLL_SPEED 60)
|
// but not when textInput is focused
|
||||||
&mut :FlxVector movement (new FlxPoint)]
|
(unless (and textInput textInput.hasFocus)
|
||||||
(when (leftKey) (-= movement.x 1))
|
(let [scrollPerSec (/ KEYBOARD_SCROLL_SPEED 60)
|
||||||
(when (rightKey) (+= movement.x 1))
|
&mut :FlxVector movement (new FlxPoint)]
|
||||||
(when (upKey) (-= movement.y 1))
|
(when (leftKey) (-= movement.x 1))
|
||||||
(when (downKey) (+= movement.y 1))
|
(when (rightKey) (+= movement.x 1))
|
||||||
(when (< 0 movement.length)
|
(when (upKey) (-= movement.y 1))
|
||||||
(set movement (movement.normalize)))
|
(when (downKey) (+= movement.y 1))
|
||||||
(movement.scale scrollPerSec)
|
(when (< 0 movement.length)
|
||||||
(+= camera.scroll.x movement.x)
|
(set movement (movement.normalize)))
|
||||||
(+= camera.scroll.y movement.y)))
|
(movement.scale scrollPerSec)
|
||||||
|
(+= camera.scroll.x movement.x)
|
||||||
|
(+= camera.scroll.y movement.y))))
|
||||||
|
|
||||||
// don't move the ui camera before ui has been placed -- new UI elements could appear offscreen
|
// don't move the ui camera before ui has been placed -- new UI elements could appear offscreen
|
||||||
(when (> uiGroup.length 0)
|
(when (> uiGroup.length 0)
|
||||||
|
Reference in New Issue
Block a user