fix uiCamera automatic scrolling

This commit is contained in:
2021-09-18 14:45:18 -06:00
parent 916e6eadb9
commit 543f8aad63

View File

@@ -141,7 +141,7 @@
(uiGroup.add ui) (uiGroup.add ui)
(set lastUI ui) (set lastUI ui)
(+= uiY ui.height) (+= uiY ui.height)
(when (> uiY FlxG.height) (-= uiCamera.y ui.height))) (when (> uiY FlxG.height) (+= uiCamera.scroll.y ui.height)))
(method :Void hideUI [:FlxSprite ui] (method :Void hideUI [:FlxSprite ui]
(uiGroup.remove ui) (uiGroup.remove ui)
@@ -152,18 +152,16 @@
(let [messageText (new FlxText 0 0 0 (message.replace "\n" "|"))] (let [messageText (new FlxText 0 0 0 (message.replace "\n" "|"))]
(showUI messageText))) (showUI messageText)))
// TODO add a UI way to call this
(method :Void clearUI [] (method :Void clearUI []
(uiGroup.kill) (uiGroup.kill)
(set uiGroup (new FlxGroup)) (set uiGroup (new FlxGroup))
(set uiGroup.cameras [uiCamera])
(add uiGroup) (add uiGroup)
(set uiY 0) (set uiY 0)
(set uiCamera.y 0)) (set uiCamera.scroll.x 0)
(set uiCamera.scroll.y 0))
// TODO add a way to scroll through messages/move the camera
(method :Void reportError [:String error] (method :Void reportError [:String error]
(let [text (new FlxText 0 0 0 (error.replace "\n" "|"))] (let [text (new FlxText 0 0 0 (error.replace "\n" "|"))]
(text.setFormat null 8 FlxColor.RED) (text.setFormat null 8 FlxColor.RED)
(showUI text))) (showUI text)))