flip ActorFlxSprite depending on facing

This commit is contained in:
2021-11-01 21:04:12 -04:00
parent 9802f3512b
commit 9dc27c99b8
3 changed files with 9 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ package hollywoo_flixel;
import kiss.Prelude;
import kiss.List;
import flixel.FlxSprite;
import hollywoo_flixel.FlxMovie;
typedef AnimationArgs = {
name:String,

View File

@@ -1,5 +1,10 @@
(defNew [:String assetPath &opt frameWidth frameHeight :Map<String,AnimationArgs> animations]
(prop :FlxStageFacing defaultFacing)
(defNew [:String assetPath &opt frameWidth frameHeight :FlxStageFacing defaultFacing :Map<String,AnimationArgs> animations]
(super)
(set this.defaultFacing (or defaultFacing Right))
(if (and frameWidth frameHeight)
(loadGraphic assetPath true frameWidth frameHeight)
(loadGraphic assetPath))

View File

@@ -22,7 +22,8 @@
(method :Void showCharacter [:Character<FlxStagePosition,FlxStageFacing,ActorFlxSprite> character :Appearance appearance :Continuation cc]
// TODO on the first appearance, show name and description (maybe? also probably not for all?)
// TODO flip sprite if facing left, and also allow for manually defined flipped frames so text doesn't mirror
// TODO also allow for manually defined flipped frames so text doesn't mirror
(set character.actor.flipX ?!(= character.stageFacing character.actor.defaultFacing))
(character.actor.setGraphicSize ACTOR_WIDTH)
(set character.actor.x
(- (case character.stagePosition