FullControl for stage positions
This commit is contained in:
@@ -40,6 +40,19 @@
|
||||
(set character.actor.flipX ?!(= character.stageFacing character.actor.defaultFacing))
|
||||
(character.actor.setGraphicSize ACTOR_WIDTH)
|
||||
(character.actor.updateHitbox)
|
||||
(ifLet [(FullControl layer rpos) character.stagePosition]
|
||||
{
|
||||
(assert (<= 0 layer SceneFlxState.LAYER_MAX) "Layer $layer is out of range 0-$SceneFlxState.LAYER_MAX")
|
||||
(let [[x y] (SpriteTools.positionOn character.actor (canvas) rpos)]
|
||||
(SpriteTools.scaleStampOn character.actor (canvas) rpos)
|
||||
(set character.actor.x x)
|
||||
(set character.actor.y y)
|
||||
(if (= layer SceneFlxState.LAYER_MAX)
|
||||
// In front of everything:
|
||||
(currentState.add character.actor)
|
||||
(.add (nth currentState.spriteLayers layer) character.actor)))
|
||||
}
|
||||
{
|
||||
(set character.actor.x
|
||||
(- (case character.stagePosition
|
||||
(Left
|
||||
@@ -73,6 +86,7 @@
|
||||
(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]
|
||||
@@ -306,18 +320,23 @@
|
||||
(currentState.add prop)))
|
||||
(cc))
|
||||
|
||||
(prop &mut :FlxSprite _canvas null)
|
||||
(method :FlxSprite canvas []
|
||||
(unless _canvas
|
||||
(set _canvas (new FlxSprite 0 0))
|
||||
(_canvas.makeGraphic FlxG.width FlxG.height FlxColor.BLACK))
|
||||
_canvas)
|
||||
|
||||
(method :Void smartShowPropOnScreen [:FlxSprite prop :Int layer :RelativePosition rpos :Continuation cc]
|
||||
(assert (<= 0 layer SceneFlxState.LAYER_MAX) "Layer $layer is out of range 0-$SceneFlxState.LAYER_MAX")
|
||||
(let [canvas (new FlxSprite 0 0)]
|
||||
(canvas.makeGraphic 1280 720 FlxColor.BLACK)
|
||||
(let [[x y] (SpriteTools.positionOn prop canvas rpos)]
|
||||
(SpriteTools.scaleStampOn prop canvas rpos)
|
||||
(let [[x y] (SpriteTools.positionOn prop (canvas) rpos)]
|
||||
(SpriteTools.scaleStampOn prop (canvas) rpos)
|
||||
(set prop.x x)
|
||||
(set prop.y y)
|
||||
(if (= layer SceneFlxState.LAYER_MAX)
|
||||
// In front of everything:
|
||||
~(currentState.add prop)
|
||||
(.add (nth currentState.spriteLayers layer) prop))))
|
||||
(currentState.add prop)
|
||||
(.add (nth currentState.spriteLayers layer) prop)))
|
||||
(cc))
|
||||
|
||||
(method :Void showPropOnScreen [:FlxSprite prop :FlxScreenPosition position :Continuation cc]
|
||||
|
@@ -14,6 +14,10 @@ enum FlxStagePosition {
|
||||
Right;
|
||||
LeftBehind;
|
||||
RightBehind;
|
||||
|
||||
// Specify the layer and position relative to screen size, or in absolute coordinates, etc.
|
||||
// AND don't move the object automatically for any reason
|
||||
FullControl(layer:Int, pos:RelativePosition);
|
||||
}
|
||||
|
||||
enum FlxStageFacing {
|
||||
|
Reference in New Issue
Block a user