swap characters in front/behind positions on speech
This commit is contained in:
@@ -44,11 +44,13 @@
|
||||
(- (case character.stagePosition
|
||||
(Left
|
||||
(set currentState.actorOnLeft character.actor)
|
||||
(set currentState.characterOnLeft character)
|
||||
STAGE_LEFT_X)
|
||||
(LeftBehind
|
||||
STAGE_LEFT_X)
|
||||
(Right
|
||||
(set currentState.actorOnRight character.actor)
|
||||
(set currentState.characterOnRight character)
|
||||
STAGE_RIGHT_X)
|
||||
(RightBehind
|
||||
STAGE_RIGHT_X)
|
||||
@@ -75,16 +77,29 @@
|
||||
|
||||
(method :Void hideCharacter [:Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite> character :Continuation cc]
|
||||
(when (= currentState.actorOnLeft character.actor)
|
||||
(set currentState.actorOnLeft null))
|
||||
(set currentState.actorOnLeft null)
|
||||
(set currentState.characterOnLeft null))
|
||||
(when (= currentState.actorOnRight character.actor)
|
||||
(set currentState.actorOnRight null))
|
||||
(set currentState.actorOnRight null)
|
||||
(set currentState.characterOnRight null))
|
||||
(currentState.remove character.actor)
|
||||
(cc))
|
||||
|
||||
(method :Void moveCharacter [:Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite> character fromPos fromFacing toPos toFacing :Continuation cc]
|
||||
(method :Void moveCharacter [:Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite> character toPos toFacing :Continuation cc]
|
||||
// Directors don't have to change the character, but FlxDirector does because that state determines
|
||||
// where actors are drawn in showCharacter:
|
||||
(set character.stagePosition toPos)
|
||||
(set character.stageFacing toFacing)
|
||||
(hideCharacter character
|
||||
->:Void (showCharacter character ReAppearance cc)))
|
||||
|
||||
(method :Void swapCharacters [:Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite> a :Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite> b :Continuation cc]
|
||||
(let [noCC ->:Void {}
|
||||
tempStagePos a.stagePosition
|
||||
tempStageFacing a.stageFacing]
|
||||
(moveCharacter a b.stagePosition b.stageFacing noCC)
|
||||
(moveCharacter b tempStagePos tempStageFacing cc)))
|
||||
|
||||
(prop &mut :Null<Continuation> nextCC)
|
||||
(method onContinue [:FlxActionDigital continueAction]
|
||||
(whenLet [cc nextCC]
|
||||
@@ -135,18 +150,32 @@
|
||||
// TODO handle text messages, wrylies, off-screen, from-phone, etc. via (case type)
|
||||
// TODO attribute on-screen dialogue to the character's stageposition
|
||||
|
||||
// When the actor is in the scene, check for an animation matching the wryly
|
||||
// When an actor is associated with the line, check for an animation matching the wryly
|
||||
// TODO allow sounds for wrylies, like the dispatch click
|
||||
(localVar &mut nameOnRight false)
|
||||
(doFor =>actorName character currentState.characters
|
||||
(when (= actorName speakerName)
|
||||
(case type
|
||||
((OnScreen character)
|
||||
(case character.stagePosition
|
||||
((or Right RightBehind) (set nameOnRight true))
|
||||
(otherwise))
|
||||
// If the character is behind another character, swap them so the speaker is front
|
||||
(case character.stagePosition
|
||||
(LeftBehind
|
||||
~"swap left"
|
||||
(swapCharacters ~character ~currentState.characterOnLeft ->:Void {}))
|
||||
(RightBehind
|
||||
~"swap Right"
|
||||
(swapCharacters ~character ~currentState.characterOnRight ->:Void {}))
|
||||
(otherwise))
|
||||
(let [actor (the ActorFlxSprite character.actor)]
|
||||
(if wryly
|
||||
(actor.playAnimation wryly)
|
||||
(actor.playAnimation "neutral")))))
|
||||
(actor.playAnimation "neutral"))))
|
||||
((or (OffScreen actor) (VoiceOver actor) (TextMessage actor) (FromPhone actor) (Custom _ actor _))
|
||||
(if wryly
|
||||
(actor.playAnimation wryly)
|
||||
(actor.playAnimation "neutral")))
|
||||
(otherwise))
|
||||
|
||||
// Make a dialog box
|
||||
(unless dialogBox
|
||||
|
@@ -2,6 +2,7 @@ package hollywoo_flixel;
|
||||
|
||||
import kiss.Prelude;
|
||||
import kiss.List;
|
||||
import kiss.FuzzyMap;
|
||||
import flixel.FlxSubState;
|
||||
import flixel.FlxState;
|
||||
import flixel.FlxSprite;
|
||||
|
@@ -1,11 +1,13 @@
|
||||
// Track which actors are in FRONT of the stage so actors can appear behind them
|
||||
(prop &mut :ActorFlxSprite actorOnLeft null)
|
||||
(prop &mut :Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite> characterOnLeft null)
|
||||
(prop &mut :ActorFlxSprite actorOnRight null)
|
||||
(prop &mut :Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite> characterOnRight null)
|
||||
|
||||
(defNew [&prop :FlxSprite setSprite &prop :SceneTime time &prop :ScenePerspective perspective]
|
||||
[
|
||||
&mut :FlxState parent null
|
||||
:Map<String,Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite>> characters (new Map)
|
||||
:FuzzyMap<Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite>> characters (new FuzzyMap<Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite>>)
|
||||
:Map<FlxSprite,FlxScreenPosition> propsOnScreen (new Map)
|
||||
]
|
||||
(super)
|
||||
|
@@ -15,7 +15,8 @@ interface Director<Set, StagePosition, StageFacing, ScreenPosition, Actor, Sound
|
||||
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 hideCharacter(character:Character<StagePosition, StageFacing, Actor>, cc:Continuation):Void;
|
||||
function moveCharacter(character:Character<StagePosition, StageFacing, Actor>, fromPos:StagePosition, fromFacing:StageFacing, toPos:StagePosition, toFacing:StageFacing, cc:Continuation):Void;
|
||||
function moveCharacter(character:Character<StagePosition, StageFacing, Actor>, toPos:StagePosition, toFacing:StageFacing, cc:Continuation):Void;
|
||||
function swapCharacters(a:Character<StagePosition, StageFacing, Actor>, b:Character<StagePosition, StageFacing, Actor>, 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 stopSong():Void;
|
||||
|
@@ -231,12 +231,24 @@
|
||||
(director.hideCharacter c cc)))
|
||||
|
||||
(hollywooMethod moveCharacter false [actorName :StagePosition newPosition :StageFacing newFacing :Continuation cc]
|
||||
(let [c (dictGet .characters (_currentScene) actorName)
|
||||
oldPosition c.stagePosition
|
||||
oldFacing c.stageFacing]
|
||||
(set c.stagePosition newPosition)
|
||||
(set c.stageFacing newFacing)
|
||||
(director.moveCharacter c oldPosition oldFacing newPosition newFacing cc)))
|
||||
(let [c (dictGet .characters (_currentScene) actorName)]
|
||||
(director.moveCharacter c newPosition newFacing ->:Void {
|
||||
(set c.stagePosition newPosition)
|
||||
(set c.stageFacing newFacing)
|
||||
(cc)
|
||||
})))
|
||||
|
||||
(hollywooMethod swapCharacters false [actorNameA actorNameB :Continuation cc]
|
||||
(let [a (dictGet .characters (_currentScene) actorNameA)
|
||||
b (dictGet .characters (_currentScene) actorNameB)]
|
||||
(director.swapCharacters a b ->:Void
|
||||
(let [tempStagePos a.stagePosition
|
||||
tempStageFacing a.stageFacing]
|
||||
(set a.stagePosition b.stagePosition)
|
||||
(set a.stageFacing b.stageFacing)
|
||||
(set b.stagePosition tempStagePos)
|
||||
(set b.stageFacing tempStageFacing)
|
||||
(cc)))))
|
||||
|
||||
// TODO moveCharacter remove them, add them to another scene
|
||||
// TODO moveCharacterAndFollow remove them, add them to another scene, set that the scene
|
||||
|
Reference in New Issue
Block a user