Add the concept of Cameras to hollywoo

This commit is contained in:
2023-03-09 07:09:41 -07:00
parent 06931e61a1
commit ce53ef2560
6 changed files with 35 additions and 9 deletions

View File

@@ -16,10 +16,11 @@ import hollywoo_flixel.FlxMovie;
import flixel.util.FlxColor; import flixel.util.FlxColor;
import flixel.text.FlxText; import flixel.text.FlxText;
import flixel.system.FlxSound; import flixel.system.FlxSound;
import flixel.FlxCamera;
import flixel.util.FlxTimer; import flixel.util.FlxTimer;
import haxe.Constraints; import haxe.Constraints;
import kiss_flixel.SpriteTools; import kiss_flixel.SpriteTools;
import haxe.ds.Option; import haxe.ds.Option;
@:build(kiss.Kiss.build()) @:build(kiss.Kiss.build())
class FlxDirector implements Director<FlxSprite, FlxScreenPosition, ActorFlxSprite, FlxSound, String, FlxSprite, FlxSound> {} class FlxDirector implements Director<FlxSprite, FlxScreenPosition, ActorFlxSprite, FlxSound, String, FlxSprite, FlxSound, FlxCamera> {}

View File

@@ -1,6 +1,6 @@
(prop :FlxActionDigital continueAction) (prop :FlxActionDigital continueAction)
(prop actionManager (new FlxActionManager)) (prop actionManager (new FlxActionManager))
(prop &mut :Movie<FlxSprite,FlxScreenPosition,ActorFlxSprite,FlxSound,String,FlxSprite,FlxSound> movie) (prop &mut :Movie<FlxSprite,FlxScreenPosition,ActorFlxSprite,FlxSound,String,FlxSprite,FlxSound,FlxCamera> movie)
(defAlias &ident flxMovie (cast movie FlxMovie)) (defAlias &ident flxMovie (cast movie FlxMovie))
(loadFrom "hollywoo-flixel" "src/hollywoo_flixel/Aliases.kiss") (loadFrom "hollywoo-flixel" "src/hollywoo_flixel/Aliases.kiss")
@@ -22,7 +22,7 @@
(spriteLayers.push g) (spriteLayers.push g)
(FlxG.state.add g)))) (FlxG.state.add g))))
(method :Void showSet [:FlxSprite setSprite :SceneTime time :ScenePerspective perspective :Appearance appearance :Continuation cc] (method :Void showSet [:FlxSprite setSprite :SceneTime time :ScenePerspective perspective :Appearance appearance :FlxCamera camera :Continuation cc]
(case appearance (case appearance
(FirstAppearance (FirstAppearance
(setSprite.setGraphicSize FlxG.width) (setSprite.setGraphicSize FlxG.width)
@@ -31,10 +31,17 @@
(setSprite.updateHitbox) (setSprite.updateHitbox)
(setSprite.screenCenter)) (setSprite.screenCenter))
(otherwise)) (otherwise))
(FlxG.cameras.remove flxMovie.uiCamera false)
(FlxG.cameras.remove flxMovie.screenCamera false)
(FlxG.cameras.add camera)
(FlxG.cameras.add flxMovie.screenCamera)
(FlxG.cameras.add flxMovie.uiCamera)
(set setSprite.cameras [camera])
(FlxG.state.add setSprite) (FlxG.state.add setSprite)
(cc)) (cc))
(method :Void hideSet [:FlxSprite set :Continuation cc] (method :Void hideSet [:FlxSprite set :FlxCamera camera :Continuation cc]
(FlxG.cameras.remove camera false)
(FlxG.state.remove set) (FlxG.state.remove set)
(cc)) (cc))
@@ -42,9 +49,10 @@
(method :Option<AutoZConfig> autoZConfig [] (Some (object zPerLayer flxMovie.STAGE_BEHIND_DY frontLayer 0))) (method :Option<AutoZConfig> autoZConfig [] (Some (object zPerLayer flxMovie.STAGE_BEHIND_DY frontLayer 0)))
(method :Void showCharacter [:Character<ActorFlxSprite> character :Appearance appearance :Continuation cc] (method :Void showCharacter [:Character<ActorFlxSprite> character :Appearance appearance :FlxCamera camera :Continuation cc]
// TODO on the first appearance, show name and description (maybe? also probably not for all?) // TODO on the first appearance, show name and description (maybe? also probably not for all?)
// TODO also allow for manually defined flipped frames so text on clothing doesn't mirror // TODO also allow for manually defined flipped frames so text on clothing doesn't mirror
(set character.actor.cameras [camera])
(set character.actor.flipX ?!(= character.stageFacing character.actor.defaultFacing)) (set character.actor.flipX ?!(= character.stageFacing character.actor.defaultFacing))
// All actors same width, display centered on x // All actors same width, display centered on x
(character.actor.setGraphicSize flxMovie.ACTOR_WIDTH) (character.actor.setGraphicSize flxMovie.ACTOR_WIDTH)
@@ -62,7 +70,7 @@
(FlxG.state.add character.actor) (FlxG.state.add character.actor)
(cc)) (cc))
(method :Void hideCharacter [:Character<ActorFlxSprite> character :Continuation cc] (method :Void hideCharacter [:Character<ActorFlxSprite> character :FlxCamera camera :Continuation cc]
(FlxG.state.remove character.actor) (FlxG.state.remove character.actor)
(cc)) (cc))
@@ -136,11 +144,13 @@
(set dialogBox (new FlxSprite flxMovie.DIALOG_X flxMovie.DIALOG_Y)) (set dialogBox (new FlxSprite flxMovie.DIALOG_X flxMovie.DIALOG_Y))
(dialogBox.makeGraphic flxMovie.DIALOG_WIDTH flxMovie.DIALOG_HEIGHT DIALOG_BOX_COLOR)) (dialogBox.makeGraphic flxMovie.DIALOG_WIDTH flxMovie.DIALOG_HEIGHT DIALOG_BOX_COLOR))
(set dialogBox.cameras [flxMovie.uiCamera])
(FlxG.state.add dialogBox) (FlxG.state.add dialogBox)
(dialogBox.revive) (dialogBox.revive)
// show the dialog // show the dialog
(unless dialogText (unless dialogText
(set dialogText (new FlxText flxMovie.DIALOG_X flxMovie.DIALOG_Y flxMovie.DIALOG_WIDTH "" DIALOG_SIZE))) (set dialogText (new FlxText flxMovie.DIALOG_X flxMovie.DIALOG_Y flxMovie.DIALOG_WIDTH "" DIALOG_SIZE)))
(set dialogText.cameras [flxMovie.uiCamera])
(FlxG.state.add dialogText) (FlxG.state.add dialogText)
(set dialogText.text text) (set dialogText.text text)
// TODO actually page through the dialog instead of sizing it down? // TODO actually page through the dialog instead of sizing it down?
@@ -152,6 +162,7 @@
// show the speaker name // show the speaker name
(unless speakerNameText (unless speakerNameText
(set speakerNameText (new FlxText flxMovie.DIALOG_X flxMovie.DIALOG_Y 0 "" DIALOG_SIZE))) (set speakerNameText (new FlxText flxMovie.DIALOG_X flxMovie.DIALOG_Y 0 "" DIALOG_SIZE)))
(set speakerNameText.cameras [flxMovie.uiCamera])
(FlxG.state.add speakerNameText) (FlxG.state.add speakerNameText)
(if speakerName (if speakerName
{ {
@@ -278,6 +289,7 @@
(cc)) (cc))
(method :Void showPropOnScreen [:FlxSprite prop :FlxScreenPosition position :Continuation cc] (method :Void showPropOnScreen [:FlxSprite prop :FlxScreenPosition position :Continuation cc]
(set prop.cameras [flxMovie.screenCamera])
// TODO give the prop reveal some time to land (add a delay to the cc) // TODO give the prop reveal some time to land (add a delay to the cc)
(ifLet [(FullControl layer rpos) position] (ifLet [(FullControl layer rpos) position]
(smartShowPropOnScreen prop layer rpos cc) (smartShowPropOnScreen prop layer rpos cc)

View File

@@ -3,6 +3,7 @@ package hollywoo_flixel;
import flixel.FlxState; import flixel.FlxState;
import flixel.FlxSprite; import flixel.FlxSprite;
import flixel.system.FlxSound; import flixel.system.FlxSound;
import flixel.FlxCamera;
import hollywoo.Director; import hollywoo.Director;
import hollywoo.Movie; import hollywoo.Movie;
import hollywoo_flixel.ActorFlxSprite; import hollywoo_flixel.ActorFlxSprite;
@@ -39,7 +40,7 @@ enum FlxScreenPosition {
/** /**
* Model/controller of a Hollywoo-Flixel film, and main execution script * Model/controller of a Hollywoo-Flixel film, and main execution script
*/ */
class FlxMovie extends Movie<FlxSprite, FlxScreenPosition, ActorFlxSprite, FlxSound, String, FlxSprite, FlxSound> { class FlxMovie extends Movie<FlxSprite, FlxScreenPosition, ActorFlxSprite, FlxSound, String, FlxSprite, FlxSound, FlxCamera> {
// Think of HollywooFlixelDSL.kiss as the corresponding Kiss file for this class! // Think of HollywooFlixelDSL.kiss as the corresponding Kiss file for this class!
public function new(director:FlxDirector, ?voiceLinesAssetPath:String) { public function new(director:FlxDirector, ?voiceLinesAssetPath:String) {
@@ -50,6 +51,8 @@ class FlxMovie extends Movie<FlxSprite, FlxScreenPosition, ActorFlxSprite, FlxSo
super(director, voiceLinesJson); super(director, voiceLinesJson);
} }
public var uiCamera:FlxCamera;
public var screenCamera:FlxCamera;
public var STAGE_LEFT_X:Float; public var STAGE_LEFT_X:Float;
public var STAGE_RIGHT_X:Float; public var STAGE_RIGHT_X:Float;

View File

@@ -64,6 +64,15 @@
(defAlias &ident flxDirector (cast director FlxDirector)) (defAlias &ident flxDirector (cast director FlxDirector))
(preload (preload
(unless uiCamera
(set uiCamera (new flixel.FlxCamera))
(set uiCamera.bgColor FlxColor.TRANSPARENT)
(flixel.FlxG.cameras.add uiCamera)
(set kiss_flixel.SimpleWindow.defaultCamera uiCamera))
(unless screenCamera
(set screenCamera (new flixel.FlxCamera))
(set screenCamera.bgColor FlxColor.TRANSPARENT)
(FlxG.cameras.add screenCamera))
// These are set here so they're defined after FlxG.width and height have been set: // These are set here so they're defined after FlxG.width and height have been set:
(set STAGE_LEFT_X 150.0) (set STAGE_LEFT_X 150.0)
(set STAGE_RIGHT_X (- FlxG.width STAGE_LEFT_X)) (set STAGE_RIGHT_X (- FlxG.width STAGE_LEFT_X))

View File

@@ -11,7 +11,7 @@ AWAITPLAYSOUND "pageFlip"
(defMacro makeSetAndScene [asset] (defMacro makeSetAndScene [asset]
`(preload `(preload
(newFlxSet ,asset ,asset) (newFlxSet ,asset ,asset)
(newSceneFromSet ,asset ,asset Day Exterior))) (newSceneFromSet ,asset ,asset Day Exterior (new FlxCamera))))
(var basicSceneKey AssetPaths.grayBackground1280x720__png) (var basicSceneKey AssetPaths.grayBackground1280x720__png)
(makeSetAndScene basicSceneKey) (makeSetAndScene basicSceneKey)
@@ -51,7 +51,7 @@ ADDCHARACTER "black" Right FacingLeft
// Speaker name not being bumped to right side for stage-right actors while intercutting: // Speaker name not being bumped to right side for stage-right actors while intercutting:
(preload (preload
(newFlxSet "intercutSet" AssetPaths.whiteBackground1280x720__png) (newFlxSet "intercutSet" AssetPaths.whiteBackground1280x720__png)
(newSceneFromSet "intercutScene" "intercutSet" Day Exterior)) (newSceneFromSet "intercutScene" "intercutSet" Day Exterior (new FlxCamera)))
SETSCENE "intercutScene" SETSCENE "intercutScene"
ADDCHARACTER "black" Right FacingLeft ADDCHARACTER "black" Right FacingLeft

View File

@@ -12,6 +12,7 @@ import flixel.FlxSprite;
import flixel.FlxSubState; import flixel.FlxSubState;
import flixel.util.FlxColor; import flixel.util.FlxColor;
import flixel.tweens.FlxTween; import flixel.tweens.FlxTween;
import flixel.FlxCamera;
@:build(kiss.AsyncEmbeddedScript.build("hollywoo-flixel", "src/hollywoo_flixel/HollywooFlixelDSL.kiss", "Test.hollywoo")) @:build(kiss.AsyncEmbeddedScript.build("hollywoo-flixel", "src/hollywoo_flixel/HollywooFlixelDSL.kiss", "Test.hollywoo"))
class Test extends FlxMovie { class Test extends FlxMovie {