stage positions behind the others
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
(var STAGE_LEFT_X 150)
|
||||
(var STAGE_RIGHT_X (- 1280 150))
|
||||
(var STAGE_BEHIND_DY -250)
|
||||
(var ACTOR_Y 500)
|
||||
(var ACTOR_WIDTH 300)
|
||||
|
||||
@@ -39,8 +40,14 @@
|
||||
(set character.actor.x
|
||||
(- (case character.stagePosition
|
||||
(Left
|
||||
(set currentState.actorOnLeft character.actor)
|
||||
STAGE_LEFT_X)
|
||||
(LeftBehind
|
||||
STAGE_LEFT_X)
|
||||
(Right
|
||||
(set currentState.actorOnRight character.actor)
|
||||
STAGE_RIGHT_X)
|
||||
(RightBehind
|
||||
STAGE_RIGHT_X)
|
||||
(otherwise (throw "unsupported stage position")))
|
||||
(/ character.actor.width 2)))
|
||||
@@ -48,10 +55,26 @@
|
||||
(let [bottom (+ character.actor.y character.actor.height)]
|
||||
(when (> bottom 720)
|
||||
(-= character.actor.y (- bottom 720))))
|
||||
(currentState.add character.actor)
|
||||
(let [&mut reAddFront false]
|
||||
(case character.stagePosition
|
||||
((or LeftBehind RightBehind)
|
||||
(set reAddFront true)
|
||||
(+= character.actor.y STAGE_BEHIND_DY))
|
||||
(otherwise))
|
||||
(when reAddFront
|
||||
(when currentState.actorOnLeft (currentState.remove currentState.actorOnLeft))
|
||||
(when currentState.actorOnRight (currentState.remove currentState.actorOnRight))
|
||||
(currentState.add character.actor)
|
||||
(when reAddFront
|
||||
(when currentState.actorOnLeft (currentState.add currentState.actorOnLeft))
|
||||
(when currentState.actorOnRight (currentState.add currentState.actorOnRight)))))
|
||||
(cc))
|
||||
|
||||
(method :Void hideCharacter [:Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite> character :Continuation cc]
|
||||
(when (= currentState.actorOnLeft character.actor)
|
||||
(set currentState.actorOnLeft null))
|
||||
(when (= currentState.actorOnRight character.actor)
|
||||
(set currentState.actorOnRight null))
|
||||
(currentState.remove character.actor)
|
||||
(cc))
|
||||
|
||||
|
@@ -12,6 +12,8 @@ import openfl.Assets;
|
||||
enum FlxStagePosition {
|
||||
Left;
|
||||
Right;
|
||||
LeftBehind;
|
||||
RightBehind;
|
||||
}
|
||||
|
||||
enum FlxStageFacing {
|
||||
|
@@ -1,3 +1,7 @@
|
||||
// Track which actors are in FRONT of the stage so actors can appear behind them
|
||||
(prop &mut :ActorFlxSprite actorOnLeft null)
|
||||
(prop &mut :ActorFlxSprite actorOnRight null)
|
||||
|
||||
(defNew [&prop :FlxSprite setSprite &prop :SceneTime time &prop :ScenePerspective perspective]
|
||||
[
|
||||
&mut :FlxState parent null
|
||||
|
Reference in New Issue
Block a user