Proper priorityID depth handling for habit puzzle drag target. Close #102
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
(set FlxG.camera pieceCamera)
|
(set FlxG.camera pieceCamera)
|
||||||
(FlxG.cameras.add uiCamera)
|
(FlxG.cameras.add uiCamera)
|
||||||
(FlxG.plugins.add (new FlxMouseControl))
|
(FlxG.plugins.add (new FlxMouseControl))
|
||||||
|
(set FlxMouseControl.sortIndex "priorityID")
|
||||||
(set bgColor FlxColor.TRANSPARENT)
|
(set bgColor FlxColor.TRANSPARENT)
|
||||||
(super.create))
|
(super.create))
|
||||||
|
|
||||||
@@ -196,6 +197,7 @@
|
|||||||
source (new FlxSprite)
|
source (new FlxSprite)
|
||||||
mask (new FlxSprite)
|
mask (new FlxSprite)
|
||||||
sourceRect (new Rectangle jig.xy.x jig.xy.y jig.wh.x jig.wh.y)]
|
sourceRect (new Rectangle jig.xy.x jig.xy.y jig.wh.x jig.wh.y)]
|
||||||
|
(set s.priorityID i)
|
||||||
(setNth spriteGrid jig.row jig.col s)
|
(setNth spriteGrid jig.row jig.col s)
|
||||||
(setNth indexGrid jig.row jig.col i)
|
(setNth indexGrid jig.row jig.col i)
|
||||||
(dictSet pieceData i jig)
|
(dictSet pieceData i jig)
|
||||||
@@ -204,22 +206,16 @@
|
|||||||
(s.enableMouseDrag false true)
|
(s.enableMouseDrag false true)
|
||||||
(set s.mouseStartDragCallback
|
(set s.mouseStartDragCallback
|
||||||
->:Void [s x y]
|
->:Void [s x y]
|
||||||
(let [t (topClickedPiece)]
|
{
|
||||||
(if (and t !(= s t))
|
// Bring currently held pieces to the front:
|
||||||
{
|
(rewardSprites.bringToFront s)
|
||||||
(s.stopDrag)
|
(set s.priorityID (+ 1 .priorityID (last (the kiss.List<FlxExtendedSprite> rewardSprites.members))))
|
||||||
(set FlxMouseControl.dragTarget t)
|
(doFor connected (recursivelyConnectedPieces s)
|
||||||
(t.startDrag)
|
(rewardSprites.bringToFront connected))
|
||||||
}
|
|
||||||
{
|
(set draggingSprite s)
|
||||||
// Bring currently held pieces to the front:
|
(set draggingLastPos (new FlxPoint s.x s.y))
|
||||||
(rewardSprites.bringToFront t)
|
})
|
||||||
(doFor connected (recursivelyConnectedPieces t)
|
|
||||||
(rewardSprites.bringToFront connected))
|
|
||||||
|
|
||||||
(set draggingSprite t)
|
|
||||||
(set draggingLastPos (new FlxPoint t.x t.y))
|
|
||||||
})))
|
|
||||||
(set s.mouseStopDragCallback
|
(set s.mouseStopDragCallback
|
||||||
->:Void [s x y]
|
->:Void [s x y]
|
||||||
{
|
{
|
||||||
@@ -309,14 +305,6 @@
|
|||||||
(shortcutHandler.start)))
|
(shortcutHandler.start)))
|
||||||
(shortcutHandler.start))
|
(shortcutHandler.start))
|
||||||
|
|
||||||
(method topClickedPiece []
|
|
||||||
(doFor idx (reverse (collect (range rewardSprites.members.length)))
|
|
||||||
(let [s (nth rewardSprites.members idx)]
|
|
||||||
(when s
|
|
||||||
(when (s.pixelsOverlapPoint (FlxG.mouse.getWorldPosition) 0xFF pieceCamera)
|
|
||||||
(return s)))))
|
|
||||||
null)
|
|
||||||
|
|
||||||
(prop &mut textY 0)
|
(prop &mut textY 0)
|
||||||
// Color currently used for making text, may be inverted or lightened to contrast with background:
|
// Color currently used for making text, may be inverted or lightened to contrast with background:
|
||||||
(prop &mut :FlxColor _color FlxColor.BLACK)
|
(prop &mut :FlxColor _color FlxColor.BLACK)
|
||||||
|
|||||||
Reference in New Issue
Block a user