hollywooFlixel actor animations by wryly

This commit is contained in:
2021-12-31 17:18:48 -07:00
parent cf87c73364
commit f2442ad618
3 changed files with 24 additions and 3 deletions

View File

@@ -2,11 +2,11 @@ package hollywoo_flixel;
import kiss.Prelude;
import kiss.List;
import kiss.FuzzyMap;
import flixel.FlxSprite;
import hollywoo_flixel.FlxMovie;
typedef AnimationArgs = {
name:String,
frames:Array<Int>,
?frameRate:Float, // default 30
?looped:Bool, // default true

View File

@@ -1,6 +1,8 @@
(prop :FlxStageFacing defaultFacing)
(defNew [:String assetPath &opt frameWidth frameHeight :FlxStageFacing defaultFacing :Map<String,AnimationArgs> animations]
(prop :FuzzyMap<String> animationNames (new FuzzyMap<String>))
(defNew [&prop :String assetPath &opt frameWidth frameHeight :FlxStageFacing defaultFacing :Map<String,AnimationArgs> animations]
(super)
(set this.defaultFacing (or defaultFacing Right))
@@ -10,10 +12,20 @@
(loadGraphic assetPath))
(when animations
(doFor =>name animationArgs animations
(dictSet animationNames name name)
(animation.add
name
animationArgs.frames
(or animationArgs.frameRate 30)
(or animationArgs.looped true)
?animationArgs.flipX
?animationArgs.flipY))))
?animationArgs.flipY))))
(method :Void playAnimation [fuzzySearchKey]
(if (animationNames.exists fuzzySearchKey)
(animation.play (dictGet animationNames fuzzySearchKey) true)
(#when debug
(print "WARNING! No animation matches $fuzzySearchKey for actor with spritesheet $assetPath"))))
(method :Void stopAnimation []
(animation.stop))

View File

@@ -104,6 +104,15 @@
(method showDialog [:String speakerName :SpeechType<FlxStagePosition,FlxStageFacing,ActorFlxSprite> type :String wryly :String text :Continuation cc]
// 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
(doFor =>actorName character currentState.characters
(when (= actorName speakerName)
(let [actor (the ActorFlxSprite character.actor)]
(if wryly
(actor.playAnimation wryly)
(actor.playAnimation "neutral")))))
// Make a dialog box
(unless dialogBox
(set dialogBox (new FlxSprite DIALOG_X DIALOG_Y))