Movie.doDialog

This commit is contained in:
2021-10-29 15:34:37 -04:00
parent d880d21baf
commit 0f4f87f96c
2 changed files with 47 additions and 10 deletions

View File

@@ -10,6 +10,8 @@ import flixel.input.mouse.FlxMouseButton;
import hollywoo.Scene;
import hollywoo.Director;
import hollywoo_flixel.FlxMovie;
import flixel.util.FlxColor;
import flixel.text.FlxText;
@:build(kiss.Kiss.build())
class FlxDirector implements Director<String, FlxStagePosition, FlxStageFacing, FlxScreenPosition, ActorFlxSprite> {}

View File

@@ -15,18 +15,22 @@
(FlxG.switchState (cast scene SceneFlxState))
(cc))
(var STAGE_LEFT_X 40)
(var STAGE_RIGHT_X 1240)
(var STAGE_LEFT_X 150)
(var STAGE_RIGHT_X (- 1280 150))
(var ACTOR_Y 500)
(var ACTOR_WIDTH 300)
(method :Void showCharacter [:Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite> character :Appearance appearance :Continuation cc]
// TODO on the first appearance, show name and description (maybe? also probably not for all?)
// TODO flip sprite if facing left, and also allow for manually defined flipped frames so text doesn't mirror
(set character.actor.x (case character.stagePosition
(Left
STAGE_LEFT_X)
(Right
STAGE_RIGHT_X)))
(character.actor.setGraphicSize ACTOR_WIDTH)
(set character.actor.x
(- (case character.stagePosition
(Left
STAGE_LEFT_X)
(Right
STAGE_RIGHT_X))
(/ character.actor.width 2)))
(set character.actor.y ACTOR_Y)
(FlxG.state.add character.actor)
(cc))
@@ -47,6 +51,37 @@
)
)
(method showDialog [:Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite> character :String dialog :Continuation cc]
// TODO show the dialog
(cc))
(var DIALOG_X 300)
(var DIALOG_WIDTH (- 1280 ACTOR_WIDTH ACTOR_WIDTH))
(var DIALOG_Y 500)
(var DIALOG_HEIGHT (- 720 DIALOG_Y))
// TODO these could be customizable to the Actor
(var DIALOG_BOX_COLOR FlxColor.BLACK)
(var DIALOG_COLOR FlxColor.WHITE)
(var DIALOG_SIZE 24)
(var &mut :FlxSprite dialogBox)
(var &mut :FlxText dialog)
(method showDialog [:Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite> character :String text :Continuation cc]
// Make a dialog box
(unless dialogBox
(set dialogBox (new FlxSprite DIALOG_X DIALOG_Y))
(dialogBox.makeGraphic DIALOG_WIDTH DIALOG_HEIGHT DIALOG_BOX_COLOR)
(FlxG.state.add dialogBox))
(dialogBox.revive)
// show the dialog
(unless dialog
(set dialog (new FlxText DIALOG_X DIALOG_Y DIALOG_WIDTH "" DIALOG_SIZE))
(FlxG.state.add dialog))
(set dialog.text text)
(dialog.revive)
// wait for input
// TODO customize the delay to the dialog length or voice-over length
(waitForInputOrDelay 5
->{
(dialog.kill)
(dialogBox.kill)
(cc)
}))