scaling, but weirdly positioned hollywoo-flixel props
This commit is contained in:
@@ -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> {}
|
||||
|
@@ -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))
|
@@ -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> {}
|
||||
|
@@ -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)))
|
@@ -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))
|
||||
|
@@ -9,9 +9,9 @@ enum Appearance {
|
||||
|
||||
typedef Continuation = Void -> Void;
|
||||
|
||||
interface Director<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song> {
|
||||
var movie(default, default):Movie<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song>;
|
||||
function showScene(scene:Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor>, appearance:Appearance, cc:Continuation):Void;
|
||||
interface Director<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song, Prop> {
|
||||
var movie(default, default):Movie<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song, Prop>;
|
||||
function showScene(scene:Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor, Prop>, appearance:Appearance, cc:Continuation):Void;
|
||||
function showCharacter(character:Character<StagePosition, StageFacing, Actor>, appearance:Appearance, cc:Continuation):Void;
|
||||
function playSound(sound:Sound, volumeMod:Float, waitForEnd:Bool, cc:Continuation):Void;
|
||||
function playSong(song:Song, volumeMod:Float, loop:Bool, waitForEnd:Bool, cc:Continuation):Void;
|
||||
@@ -19,4 +19,7 @@ interface Director<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound
|
||||
function startWaitForInput(cc:Continuation):Void;
|
||||
function stopWaitForInput():Void;
|
||||
function showDialog(speakerName:String, type:SpeechType<StagePosition, StageFacing, Actor>, wryly:String, dialog:String, cc:Continuation):Void;
|
||||
function showPropOnScreen(prop:Prop, position:ScreenPosition, cc:Continuation):Void;
|
||||
// TODO showPropOnStage
|
||||
function hideProp(prop:Prop, cc:Continuation):Void;
|
||||
}
|
||||
|
@@ -17,8 +17,8 @@ enum DelayHandling {
|
||||
* Model/controller of a Hollywoo film, and main execution script
|
||||
*/
|
||||
@:build(kiss.Kiss.build())
|
||||
class Movie<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song> extends AsyncEmbeddedScript {
|
||||
class Movie<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song, Prop> extends AsyncEmbeddedScript {
|
||||
// TODO for some reason this wasn't working when declared in Movie.kiss:
|
||||
// Mutable representation of frames in time:
|
||||
var scenes:Map<String, Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor>> = [];
|
||||
var scenes:Map<String, Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor, Prop>> = [];
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
(prop :Map<String,Actor> actors (new Map))
|
||||
(prop :Map<String,Sound> sounds (new Map))
|
||||
(prop :Map<String,Song> songs (new Map))
|
||||
(prop :Map<String,Prop> props (new Map))
|
||||
|
||||
(prop &mut :DelayHandling delayHandling AutoWithSkip)
|
||||
|
||||
@@ -29,7 +30,7 @@
|
||||
(defNew
|
||||
[
|
||||
// "View" in the Model-View-Controller architecture:
|
||||
&prop :Director<Set,StagePosition,StageFacing,ScreenPosition,Actor,Sound,Song> director
|
||||
&prop :Director<Set,StagePosition,StageFacing,ScreenPosition,Actor,Sound,Song,Prop> director
|
||||
]
|
||||
|
||||
(set director.movie this)
|
||||
@@ -73,11 +74,13 @@
|
||||
(dictGet sets setKey)
|
||||
characters
|
||||
(new Map)
|
||||
propsOnScreen
|
||||
(new Map)
|
||||
]
|
||||
time
|
||||
perspective)))
|
||||
|
||||
(method newScene [name :Scene<Set,StagePosition,StageFacing,ScreenPosition,Actor> scene]
|
||||
(method newScene [name :Scene<Set,StagePosition,StageFacing,ScreenPosition,Actor,Prop> scene]
|
||||
(assert isLoading)
|
||||
(dictSet scenes name scene))
|
||||
|
||||
@@ -140,6 +143,19 @@
|
||||
// TODO moveCharacter remove them, add them to another scene
|
||||
// TODO moveCharacterAndFollow remove them, add them to another scene, set that the scene
|
||||
|
||||
(method newProp [name :Prop prop]
|
||||
(assert isLoading)
|
||||
(dictSet props name prop))
|
||||
|
||||
(method addPropToScreen [name :ScreenPosition position :Continuation cc]
|
||||
(dictSet .propsOnScreen (_currentScene) name (dictGet props name))
|
||||
(director.showPropOnScreen (dictGet props name) position cc))
|
||||
|
||||
(method removePropFromScrene [name :Continuation cc]
|
||||
(director.hideProp (dictGet props name) cc))
|
||||
|
||||
// TODO removeProp
|
||||
|
||||
// Dialogue:
|
||||
|
||||
(method superText [text cc]
|
||||
|
@@ -28,9 +28,11 @@ enum SpeechType<StagePosition, StageFacing, Actor> {
|
||||
Custom(type:String, actor:Actor, args:Dynamic);
|
||||
}
|
||||
|
||||
typedef Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor> = {
|
||||
typedef Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor, Prop> = {
|
||||
set:Set,
|
||||
characters:Map<String, Character<StagePosition, StageFacing, Actor>>,
|
||||
propsOnScreen:Map<String, Prop>,
|
||||
// TODO props on stage
|
||||
time:SceneTime,
|
||||
perspective:ScenePerspective
|
||||
};
|
||||
|
Reference in New Issue
Block a user