scaling, but weirdly positioned hollywoo-flixel props

This commit is contained in:
2021-11-03 12:25:11 -04:00
parent 65d91984aa
commit 0654b550a3
5 changed files with 34 additions and 6 deletions

View File

@@ -17,4 +17,4 @@ import flixel.system.FlxSound;
import flixel.util.FlxTimer;
@:build(kiss.Kiss.build())
class FlxDirector implements Director<String, FlxStagePosition, FlxStageFacing, FlxScreenPosition, ActorFlxSprite, FlxSound, String> {}
class FlxDirector implements Director<String, FlxStagePosition, FlxStageFacing, FlxScreenPosition, ActorFlxSprite, FlxSound, String, FlxSprite> {}

View File

@@ -1,6 +1,6 @@
(prop :FlxActionDigital continueAction)
(prop actionManager (new FlxActionManager))
(prop &mut :Movie<String,FlxStagePosition,FlxStageFacing,FlxScreenPosition,ActorFlxSprite,FlxSound,String> movie)
(prop &mut :Movie<String,FlxStagePosition,FlxStageFacing,FlxScreenPosition,ActorFlxSprite,FlxSound,String,FlxSprite> movie)
(defNew []
(set continueAction (new FlxActionDigital "Continue" onContinue))
@@ -12,7 +12,7 @@
(set actionManager.resetOnStateSwitch NONE))
(prop &mut :SceneFlxState currentState)
(method :Void showScene [:Scene<String,FlxStagePosition,FlxStageFacing,FlxScreenPosition,ActorFlxSprite> scene :Appearance appearance :Continuation cc]
(method :Void showScene [:Scene<String,FlxStagePosition,FlxStageFacing,FlxScreenPosition,ActorFlxSprite,FlxSprite> scene :Appearance appearance :Continuation cc]
// Close the last scene state
(when currentState
(currentState.close))
@@ -98,7 +98,7 @@
// wait for input or delay
// TODO customize the delay in a more sophisticated way to the dialog length or voice-over length,
// or rely on FlxTypeText to add breathing room
(movie.delay .length (text.split " ")
(movie.delay (+ 5 (* 0.5 .length (text.split " ")))
->{
(dialogText.kill)
(speakerNameText.kill)
@@ -130,3 +130,24 @@
(unless waitForEnd (cc)))
(method :Void stopSong [] (when music (music.stop)))
(var PROP_MIN_WIDTH 200)
(var PROP_MAX_WIDTH 500)
(method :Void showPropOnScreen [:FlxSprite prop :FlxScreenPosition position :Continuation cc]
// TODO assign the other possible positions
(let [[x y]
(case position
(Center [(/ 1280 2) (/ 720 2)])
(otherwise (throw "not implemented")))]
(let [width (min (max prop.width PROP_MIN_WIDTH) PROP_MAX_WIDTH)]
(prop.setGraphicSize width)
(set prop.x (- x (/ prop.width 2)))
(set prop.y (- y (/ (* prop.height prop.scale.y) 2)))
(currentState.add prop)))
// TODO give the prop reveal some time to land
(cc))
(method :Void hideProp [prop cc]
(currentState.remove prop)
(cc))

View File

@@ -24,9 +24,10 @@ enum FlxScreenPosition {
LowerRight;
LowerCenter;
UpperCenter;
Center;
}
/**
* Model/controller of a Hollywoo-Flixel film, and main execution script
*/
class FlxMovie extends Movie<String, FlxStagePosition, FlxStageFacing, FlxScreenPosition, ActorFlxSprite, FlxSound, String> {}
class FlxMovie extends Movie<String, FlxStagePosition, FlxStageFacing, FlxScreenPosition, ActorFlxSprite, FlxSound, String, FlxSprite> {}

View File

@@ -12,4 +12,9 @@
(let [s (FlxG.sound.load path)]
(set s.volume volume)
(set s.persist true)
(newSound name s)))
(newSound name s)))
(method newFlxProp [name path]
(let [propSprite (new FlxSprite 0 0)]
(propSprite.loadGraphic path)
(newProp name propSprite)))

View File

@@ -1,6 +1,7 @@
(defNew [&prop :FlxSprite setSprite &prop :SceneTime time &prop :ScenePerspective perspective]
[
:Map<String,Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite>> characters (new Map)
:Map<FlxSprite,FlxScreenPosition> propsOnScreen (new Map)
]
(super)
(add setSprite))