prop layers for full screen position control
This commit is contained in:
@@ -253,9 +253,8 @@
|
||||
(var PROP_MIN_WIDTH 200)
|
||||
(var PROP_MAX_WIDTH 500)
|
||||
|
||||
(method :Void showPropOnScreen [:FlxSprite prop :FlxScreenPosition position :Continuation cc]
|
||||
(method :Void quickShowPropOnScreen [:FlxSprite prop :FlxScreenPosition position :Continuation cc]
|
||||
// TODO assign the other possible positions
|
||||
// TODO allow absolute position and relative position by screen percentages
|
||||
(let [[x y]
|
||||
(case position
|
||||
(Center [(/ 1280 2) (/ 720 2)])
|
||||
@@ -277,11 +276,27 @@
|
||||
(-= prop.y (- propBottom DIALOG_Y))))
|
||||
|
||||
(currentState.add prop)))
|
||||
// TODO give the prop reveal some time to land
|
||||
(cc))
|
||||
|
||||
(method :Void hideProp [prop cc]
|
||||
(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)
|
||||
(.add (nth currentState.spriteLayers layer) prop)))
|
||||
(cc))
|
||||
|
||||
(method :Void showPropOnScreen [:FlxSprite prop :FlxScreenPosition position :Continuation cc]
|
||||
// TODO give the prop reveal some time to land (add a delay to the cc)
|
||||
(ifLet [(FullControl layer rpos) position]
|
||||
(smartShowPropOnScreen prop layer rpos cc)
|
||||
(quickShowPropOnScreen prop position cc)))
|
||||
|
||||
(method :Void hideProp [:FlxSprite prop cc]
|
||||
(currentState.remove prop)
|
||||
(doFor layer currentState.spriteLayers
|
||||
(layer.remove prop))
|
||||
(cc))
|
||||
|
||||
(prop :Array<FlxText> creditsText [])
|
||||
|
@@ -22,6 +22,7 @@ enum FlxStageFacing {
|
||||
}
|
||||
|
||||
enum FlxScreenPosition {
|
||||
// Shortcuts
|
||||
UpperLeft;
|
||||
UpperRight;
|
||||
LowerLeft;
|
||||
@@ -29,6 +30,9 @@ enum FlxScreenPosition {
|
||||
LowerCenter;
|
||||
UpperCenter;
|
||||
Center;
|
||||
|
||||
// Specify the layer and position relative to screen size, or in absolute coordinates, etc.
|
||||
FullControl(layer:Int, pos:RelativePosition);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import kiss.FuzzyMap;
|
||||
import flixel.FlxSubState;
|
||||
import flixel.FlxState;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.group.FlxGroup;
|
||||
import flixel.FlxG;
|
||||
import hollywoo.Scene;
|
||||
import hollywoo_flixel.FlxMovie;
|
||||
|
@@ -4,6 +4,10 @@
|
||||
(prop &mut :ActorFlxSprite actorOnRight null)
|
||||
(prop &mut :Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite> characterOnRight null)
|
||||
|
||||
// Track props in an arbitrary number of layers
|
||||
(prop :Array<FlxTypedGroup<FlxSprite>> spriteLayers [])
|
||||
(var LAYER_MAX 5)
|
||||
|
||||
(defNew [&prop :FlxSprite setSprite &prop :SceneTime time &prop :ScenePerspective perspective]
|
||||
[
|
||||
&mut :FlxState parent null
|
||||
@@ -11,7 +15,12 @@
|
||||
:Map<FlxSprite,FlxScreenPosition> propsOnScreen (new Map)
|
||||
]
|
||||
(super)
|
||||
(add setSprite))
|
||||
(add setSprite)
|
||||
// TODO characters will be in front of every prop layer -- characters need their own group layer
|
||||
(doFor i (range LAYER_MAX)
|
||||
(let [g (new FlxTypedGroup<FlxSprite>)]
|
||||
(spriteLayers.push g)
|
||||
(add g))))
|
||||
|
||||
(method &override :Void create []
|
||||
(super.create)
|
||||
|
Reference in New Issue
Block a user