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 []
(FlxG.camera.extendScrollBounds this PlayState.SCROLL_BOUND_MARGIN)
(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]
(super.update elapsed)

View File

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

View File

@@ -7,6 +7,8 @@
(FlxG.plugins.add (new FlxMouseControl))
(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
(let [archiveDir
@@ -95,12 +97,19 @@
(prop &mut :EntrySpriteSystem spriteSystem)
(set spriteSystem (new EntrySpriteSystem "!done" "Playground-MAIN" this controller))
(archive.addSystem spriteSystem)
(prop &mut :EntrySpriteDepthSystem spriteDepthSystem)
(set spriteDepthSystem (new EntrySpriteDepthSystem this spriteSystem))
(archive.addSystem spriteDepthSystem)
(archive.processSystems this)
(FlxG.camera.calculateScrollBounds entryGroup SCROLL_BOUND_MARGIN))
(method &override :Void update [:Float elapsed]
(super.update elapsed)
(spriteDepthSystem.process archive)
(when FlxG.keys.justPressed.ESCAPE
(Sys.exit 0))
@@ -133,6 +142,15 @@
(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
(when (> uiGroup.length 0)
(unless (and textInput textInput.hasFocus)
@@ -214,14 +232,15 @@
(var SCROLL_BOUND_MARGIN 200)
(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
(archive.processSystems this)
// Do a second loop through the systems, so Playground systems that trigger Core systems have their effects processed
(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
// by refreshEntry()
(when (spriteSystem.entries.exists e.id)