fix hollywoo set sprites loading on the fly

This commit is contained in:
2021-11-02 18:58:59 -04:00
parent 37fdb36376
commit 613e3cf4d2
3 changed files with 20 additions and 15 deletions

View File

@@ -10,9 +10,11 @@
(FlxG.inputs.add actionManager)
(set actionManager.resetOnStateSwitch NONE))
(prop &mut :SceneFlxState currentState)
(method :Void showScene [:Scene<String,FlxStagePosition,FlxStageFacing,FlxScreenPosition,ActorFlxSprite> scene :Appearance appearance :Continuation cc]
// TODO on the first appearance, give a super (for some scenes but probably not others... hm....)
(FlxG.switchState (cast scene SceneFlxState))
(set currentState (cast scene SceneFlxState))
(FlxG.switchState currentState)
(cc))
(var STAGE_LEFT_X 150)
@@ -33,7 +35,7 @@
STAGE_RIGHT_X))
(/ character.actor.width 2)))
(set character.actor.y ACTOR_Y)
(FlxG.state.add character.actor)
(currentState.add character.actor)
(cc))
(prop &mut :Null<Continuation> nextCC)
@@ -72,18 +74,18 @@
(unless dialogBox
(set dialogBox (new FlxSprite DIALOG_X DIALOG_Y))
(dialogBox.makeGraphic DIALOG_WIDTH DIALOG_HEIGHT DIALOG_BOX_COLOR)
(FlxG.state.add dialogBox))
(currentState.add dialogBox))
(dialogBox.revive)
// show the dialog
(unless dialogText
// TODO use FlxTypeText to reveal dialog gradually
(set dialogText (new FlxText DIALOG_X DIALOG_Y DIALOG_WIDTH "" DIALOG_SIZE))
(FlxG.state.add dialogText))
(currentState.add dialogText))
(set dialogText.text text)
// show the speaker name
(unless speakerNameText
(set speakerNameText (new FlxText DIALOG_X DIALOG_Y DIALOG_WIDTH "" DIALOG_SIZE))
(FlxG.state.add speakerNameText))
(currentState.add speakerNameText))
(if speakerName
{
(set speakerNameText.text "${speakerName}:")

View File

@@ -1,5 +1,10 @@
(loadFrom "hollywoo" "src/hollywoo/HollywooDSL.kiss")
(method newFlxScene [name set time perspective]
(let [setSprite (new FlxSprite 0 0)]
(setSprite.loadGraphic (dictGet sets set))
(newScene name (cast (new SceneFlxState setSprite time perspective)))))
(method newFlxSound [name path &opt :Float volume]
(set volume (or volume 1))
(assert (<= 0 volume 1))

View File

@@ -1,19 +1,17 @@
(defNew [&prop :String set &prop :SceneTime time &prop :ScenePerspective perspective]
(defNew [&prop :FlxSprite setSprite &prop :SceneTime time &prop :ScenePerspective perspective]
[
:Map<String,Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite>> characters (new Map)
]
(super))
(super)
(add setSprite))
(method &override :Void create []
(super.create)
(let [setSprite (new FlxSprite 0 0)]
(setSprite.loadGraphic set)
(when (> setSprite.width FlxG.width)
(setSprite.setGraphicSize FlxG.width))
(when (> setSprite.height FlxG.height)
(setSprite.setGraphicSize 0 FlxG.height))
(setSprite.screenCenter)
(add setSprite)))
(when (> setSprite.width FlxG.width)
(setSprite.setGraphicSize FlxG.width))
(when (> setSprite.height FlxG.height)
(setSprite.setGraphicSize 0 FlxG.height))
(setSprite.screenCenter))
(method &override :Void update [:Float elapsed]
(super.update elapsed))