Add the concept of Cameras to hollywoo
This commit is contained in:
@@ -16,10 +16,11 @@ import hollywoo_flixel.FlxMovie;
|
||||
import flixel.util.FlxColor;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.system.FlxSound;
|
||||
import flixel.FlxCamera;
|
||||
import flixel.util.FlxTimer;
|
||||
import haxe.Constraints;
|
||||
import kiss_flixel.SpriteTools;
|
||||
import haxe.ds.Option;
|
||||
|
||||
@: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> {}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
(prop :FlxActionDigital continueAction)
|
||||
(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))
|
||||
(loadFrom "hollywoo-flixel" "src/hollywoo_flixel/Aliases.kiss")
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
(spriteLayers.push 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
|
||||
(FirstAppearance
|
||||
(setSprite.setGraphicSize FlxG.width)
|
||||
@@ -31,10 +31,17 @@
|
||||
(setSprite.updateHitbox)
|
||||
(setSprite.screenCenter))
|
||||
(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)
|
||||
(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)
|
||||
(cc))
|
||||
|
||||
@@ -42,9 +49,10 @@
|
||||
|
||||
(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 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))
|
||||
// All actors same width, display centered on x
|
||||
(character.actor.setGraphicSize flxMovie.ACTOR_WIDTH)
|
||||
@@ -62,7 +70,7 @@
|
||||
(FlxG.state.add character.actor)
|
||||
(cc))
|
||||
|
||||
(method :Void hideCharacter [:Character<ActorFlxSprite> character :Continuation cc]
|
||||
(method :Void hideCharacter [:Character<ActorFlxSprite> character :FlxCamera camera :Continuation cc]
|
||||
(FlxG.state.remove character.actor)
|
||||
(cc))
|
||||
|
||||
@@ -136,11 +144,13 @@
|
||||
(set dialogBox (new FlxSprite flxMovie.DIALOG_X flxMovie.DIALOG_Y))
|
||||
(dialogBox.makeGraphic flxMovie.DIALOG_WIDTH flxMovie.DIALOG_HEIGHT DIALOG_BOX_COLOR))
|
||||
|
||||
(set dialogBox.cameras [flxMovie.uiCamera])
|
||||
(FlxG.state.add dialogBox)
|
||||
(dialogBox.revive)
|
||||
// show the dialog
|
||||
(unless dialogText
|
||||
(set dialogText (new FlxText flxMovie.DIALOG_X flxMovie.DIALOG_Y flxMovie.DIALOG_WIDTH "" DIALOG_SIZE)))
|
||||
(set dialogText.cameras [flxMovie.uiCamera])
|
||||
(FlxG.state.add dialogText)
|
||||
(set dialogText.text text)
|
||||
// TODO actually page through the dialog instead of sizing it down?
|
||||
@@ -152,6 +162,7 @@
|
||||
// show the speaker name
|
||||
(unless speakerNameText
|
||||
(set speakerNameText (new FlxText flxMovie.DIALOG_X flxMovie.DIALOG_Y 0 "" DIALOG_SIZE)))
|
||||
(set speakerNameText.cameras [flxMovie.uiCamera])
|
||||
(FlxG.state.add speakerNameText)
|
||||
(if speakerName
|
||||
{
|
||||
@@ -278,6 +289,7 @@
|
||||
(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)
|
||||
(ifLet [(FullControl layer rpos) position]
|
||||
(smartShowPropOnScreen prop layer rpos cc)
|
||||
|
@@ -3,6 +3,7 @@ package hollywoo_flixel;
|
||||
import flixel.FlxState;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.system.FlxSound;
|
||||
import flixel.FlxCamera;
|
||||
import hollywoo.Director;
|
||||
import hollywoo.Movie;
|
||||
import hollywoo_flixel.ActorFlxSprite;
|
||||
@@ -39,7 +40,7 @@ enum FlxScreenPosition {
|
||||
/**
|
||||
* 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!
|
||||
|
||||
public function new(director:FlxDirector, ?voiceLinesAssetPath:String) {
|
||||
@@ -50,6 +51,8 @@ class FlxMovie extends Movie<FlxSprite, FlxScreenPosition, ActorFlxSprite, FlxSo
|
||||
|
||||
super(director, voiceLinesJson);
|
||||
}
|
||||
public var uiCamera:FlxCamera;
|
||||
public var screenCamera:FlxCamera;
|
||||
|
||||
public var STAGE_LEFT_X:Float;
|
||||
public var STAGE_RIGHT_X:Float;
|
||||
|
@@ -64,6 +64,15 @@
|
||||
(defAlias &ident flxDirector (cast director FlxDirector))
|
||||
|
||||
(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:
|
||||
(set STAGE_LEFT_X 150.0)
|
||||
(set STAGE_RIGHT_X (- FlxG.width STAGE_LEFT_X))
|
||||
|
Reference in New Issue
Block a user