nat playground buggy z sorting

This commit is contained in:
2022-06-28 17:09:34 +00:00
parent 46becb3b63
commit 4413114218
3 changed files with 24 additions and 4 deletions

View File

@@ -43,7 +43,8 @@
(method savePos [] (method savePos []
(FlxG.camera.extendScrollBounds this PlayState.SCROLL_BOUND_MARGIN) (FlxG.camera.extendScrollBounds this PlayState.SCROLL_BOUND_MARGIN)
(withWritableComponents archive e [positions Positions] (withWritableComponents archive e [positions Positions]
(dictSet positions positionKey (object x (cast this.x Float) y (cast this.y Float) z 0.0)))) (let [pos (dictGet positions positionKey)]
(dictSet positions positionKey (object x (cast this.x Float) y (cast this.y Float) z pos.z)))))
(method &override :Void update [:Float elapsed] (method &override :Void update [:Float elapsed]
(super.update elapsed) (super.update elapsed)

View File

@@ -3,7 +3,7 @@
(prop :Map<String,EntrySprite> sprites (new Map)) (prop :Map<String,EntrySprite> sprites (new Map))
(defNew [:String tagFilterString (defNew [:String tagFilterString
:String positionKey &prop :String positionKey
:PlayState playState :PlayState playState
&prop :ArchiveController controller] &prop :ArchiveController controller]
(super (super

View File

@@ -7,6 +7,8 @@
(FlxG.plugins.add (new FlxMouseControl)) (FlxG.plugins.add (new FlxMouseControl))
(set FlxG.sound.muteKeys null) (set FlxG.sound.muteKeys null)
(set FlxG.sound.volumeDownKeys null)
(set FlxG.sound.volumeUpKeys null)
// TODO find a better way to pass the archiveDir to a HaxeFlixel game // TODO find a better way to pass the archiveDir to a HaxeFlixel game
(let [archiveDir (let [archiveDir
@@ -95,12 +97,19 @@
(prop &mut :EntrySpriteSystem spriteSystem) (prop &mut :EntrySpriteSystem spriteSystem)
(set spriteSystem (new EntrySpriteSystem "!done" "Playground-MAIN" this controller)) (set spriteSystem (new EntrySpriteSystem "!done" "Playground-MAIN" this controller))
(archive.addSystem spriteSystem) (archive.addSystem spriteSystem)
(prop &mut :EntrySpriteDepthSystem spriteDepthSystem)
(set spriteDepthSystem (new EntrySpriteDepthSystem this spriteSystem))
(archive.addSystem spriteDepthSystem)
(archive.processSystems this) (archive.processSystems this)
(FlxG.camera.calculateScrollBounds entryGroup SCROLL_BOUND_MARGIN)) (FlxG.camera.calculateScrollBounds entryGroup SCROLL_BOUND_MARGIN))
(method &override :Void update [:Float elapsed] (method &override :Void update [:Float elapsed]
(super.update elapsed) (super.update elapsed)
(spriteDepthSystem.process archive)
(when FlxG.keys.justPressed.ESCAPE (when FlxG.keys.justPressed.ESCAPE
(Sys.exit 0)) (Sys.exit 0))
@@ -133,6 +142,15 @@
(FlxG.camera.updateScrollWheelZoom elapsed 1) (FlxG.camera.updateScrollWheelZoom elapsed 1)
// +/- keys to change an entry's z
(doFor e (controller.getSelectedEntries)
(when FlxG.keys.justPressed.MINUS
(withWritableComponents archive e [positions Positions]
(-= .z (dictGet positions spriteSystem.positionKey) 1)))
(when FlxG.keys.justPressed.PLUS
(withWritableComponents archive e [positions Positions]
(+= .z (dictGet positions spriteSystem.positionKey) 1))))
// 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)
(unless (and textInput textInput.hasFocus) (unless (and textInput textInput.hasFocus)
@@ -214,14 +232,15 @@
(var SCROLL_BOUND_MARGIN 200) (var SCROLL_BOUND_MARGIN 200)
(method handleChanges [:Archive archive :ChangeSet changeSet] (method handleChanges [:Archive archive :ChangeSet changeSet]
(doFor e changeSet (when changeSet
// process the WikipediaImageSystem and run spriteSystem process on newly created entries that get one // process the WikipediaImageSystem and run spriteSystem process on newly created entries that get one
(archive.processSystems this) (archive.processSystems this)
// Do a second loop through the systems, so Playground systems that trigger Core systems have their effects processed // Do a second loop through the systems, so Playground systems that trigger Core systems have their effects processed
(archive.processSystems this) (archive.processSystems this)
(FlxG.camera.calculateScrollBounds entryGroup SCROLL_BOUND_MARGIN) (FlxG.camera.calculateScrollBounds entryGroup SCROLL_BOUND_MARGIN))
(doFor e changeSet
// Entries whose data changed to remove them from the sprite pool will already have been removed // Entries whose data changed to remove them from the sprite pool will already have been removed
// by refreshEntry() // by refreshEntry()
(when (spriteSystem.entries.exists e.id) (when (spriteSystem.entries.exists e.id)