scaling, but weirdly positioned hollywoo-flixel props
This commit is contained in:
@@ -17,4 +17,4 @@ import flixel.system.FlxSound;
|
|||||||
import flixel.util.FlxTimer;
|
import flixel.util.FlxTimer;
|
||||||
|
|
||||||
@:build(kiss.Kiss.build())
|
@: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 :FlxActionDigital continueAction)
|
||||||
(prop actionManager (new FlxActionManager))
|
(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 []
|
(defNew []
|
||||||
(set continueAction (new FlxActionDigital "Continue" onContinue))
|
(set continueAction (new FlxActionDigital "Continue" onContinue))
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
(set actionManager.resetOnStateSwitch NONE))
|
(set actionManager.resetOnStateSwitch NONE))
|
||||||
|
|
||||||
(prop &mut :SceneFlxState currentState)
|
(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
|
// Close the last scene state
|
||||||
(when currentState
|
(when currentState
|
||||||
(currentState.close))
|
(currentState.close))
|
||||||
@@ -98,7 +98,7 @@
|
|||||||
// wait for input or delay
|
// wait for input or delay
|
||||||
// TODO customize the delay in a more sophisticated way to the dialog length or voice-over length,
|
// 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
|
// or rely on FlxTypeText to add breathing room
|
||||||
(movie.delay .length (text.split " ")
|
(movie.delay (+ 5 (* 0.5 .length (text.split " ")))
|
||||||
->{
|
->{
|
||||||
(dialogText.kill)
|
(dialogText.kill)
|
||||||
(speakerNameText.kill)
|
(speakerNameText.kill)
|
||||||
@@ -130,3 +130,24 @@
|
|||||||
(unless waitForEnd (cc)))
|
(unless waitForEnd (cc)))
|
||||||
|
|
||||||
(method :Void stopSong [] (when music (music.stop)))
|
(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;
|
LowerRight;
|
||||||
LowerCenter;
|
LowerCenter;
|
||||||
UpperCenter;
|
UpperCenter;
|
||||||
|
Center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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<String, FlxStagePosition, FlxStageFacing, FlxScreenPosition, ActorFlxSprite, FlxSound, String> {}
|
class FlxMovie extends Movie<String, FlxStagePosition, FlxStageFacing, FlxScreenPosition, ActorFlxSprite, FlxSound, String, FlxSprite> {}
|
||||||
|
@@ -13,3 +13,8 @@
|
|||||||
(set s.volume volume)
|
(set s.volume volume)
|
||||||
(set s.persist true)
|
(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]
|
(defNew [&prop :FlxSprite setSprite &prop :SceneTime time &prop :ScenePerspective perspective]
|
||||||
[
|
[
|
||||||
:Map<String,Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite>> characters (new Map)
|
:Map<String,Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite>> characters (new Map)
|
||||||
|
:Map<FlxSprite,FlxScreenPosition> propsOnScreen (new Map)
|
||||||
]
|
]
|
||||||
(super)
|
(super)
|
||||||
(add setSprite))
|
(add setSprite))
|
||||||
|
@@ -9,9 +9,9 @@ enum Appearance {
|
|||||||
|
|
||||||
typedef Continuation = Void -> Void;
|
typedef Continuation = Void -> Void;
|
||||||
|
|
||||||
interface Director<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song> {
|
interface Director<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song, Prop> {
|
||||||
var movie(default, default):Movie<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song>;
|
var movie(default, default):Movie<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound, Song, Prop>;
|
||||||
function showScene(scene:Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor>, appearance:Appearance, cc:Continuation):Void;
|
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 showCharacter(character:Character<StagePosition, StageFacing, Actor>, appearance:Appearance, cc:Continuation):Void;
|
||||||
function playSound(sound:Sound, volumeMod:Float, waitForEnd:Bool, 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;
|
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 startWaitForInput(cc:Continuation):Void;
|
||||||
function stopWaitForInput():Void;
|
function stopWaitForInput():Void;
|
||||||
function showDialog(speakerName:String, type:SpeechType<StagePosition, StageFacing, Actor>, wryly:String, dialog:String, cc:Continuation):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
|
* Model/controller of a Hollywoo film, and main execution script
|
||||||
*/
|
*/
|
||||||
@:build(kiss.Kiss.build())
|
@: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:
|
// TODO for some reason this wasn't working when declared in Movie.kiss:
|
||||||
// Mutable representation of frames in time:
|
// 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,Actor> actors (new Map))
|
||||||
(prop :Map<String,Sound> sounds (new Map))
|
(prop :Map<String,Sound> sounds (new Map))
|
||||||
(prop :Map<String,Song> songs (new Map))
|
(prop :Map<String,Song> songs (new Map))
|
||||||
|
(prop :Map<String,Prop> props (new Map))
|
||||||
|
|
||||||
(prop &mut :DelayHandling delayHandling AutoWithSkip)
|
(prop &mut :DelayHandling delayHandling AutoWithSkip)
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@
|
|||||||
(defNew
|
(defNew
|
||||||
[
|
[
|
||||||
// "View" in the Model-View-Controller architecture:
|
// "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)
|
(set director.movie this)
|
||||||
@@ -73,11 +74,13 @@
|
|||||||
(dictGet sets setKey)
|
(dictGet sets setKey)
|
||||||
characters
|
characters
|
||||||
(new Map)
|
(new Map)
|
||||||
|
propsOnScreen
|
||||||
|
(new Map)
|
||||||
]
|
]
|
||||||
time
|
time
|
||||||
perspective)))
|
perspective)))
|
||||||
|
|
||||||
(method newScene [name :Scene<Set,StagePosition,StageFacing,ScreenPosition,Actor> scene]
|
(method newScene [name :Scene<Set,StagePosition,StageFacing,ScreenPosition,Actor,Prop> scene]
|
||||||
(assert isLoading)
|
(assert isLoading)
|
||||||
(dictSet scenes name scene))
|
(dictSet scenes name scene))
|
||||||
|
|
||||||
@@ -140,6 +143,19 @@
|
|||||||
// TODO moveCharacter remove them, add them to another scene
|
// TODO moveCharacter remove them, add them to another scene
|
||||||
// TODO moveCharacterAndFollow remove them, add them to another scene, set that the 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:
|
// Dialogue:
|
||||||
|
|
||||||
(method superText [text cc]
|
(method superText [text cc]
|
||||||
|
@@ -28,9 +28,11 @@ enum SpeechType<StagePosition, StageFacing, Actor> {
|
|||||||
Custom(type:String, actor:Actor, args:Dynamic);
|
Custom(type:String, actor:Actor, args:Dynamic);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor> = {
|
typedef Scene<Set, StagePosition, StageFacing, ScreenPosition, Actor, Prop> = {
|
||||||
set:Set,
|
set:Set,
|
||||||
characters:Map<String, Character<StagePosition, StageFacing, Actor>>,
|
characters:Map<String, Character<StagePosition, StageFacing, Actor>>,
|
||||||
|
propsOnScreen:Map<String, Prop>,
|
||||||
|
// TODO props on stage
|
||||||
time:SceneTime,
|
time:SceneTime,
|
||||||
perspective:ScenePerspective
|
perspective:ScenePerspective
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user