From 37fdb36376410de05a6e0c103af0122d50a9057e Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 1 Nov 2021 21:04:12 -0400 Subject: [PATCH] flip ActorFlxSprite depending on facing --- src/hollywoo_flixel/ActorFlxSprite.hx | 1 + src/hollywoo_flixel/ActorFlxSprite.kiss | 7 ++++++- src/hollywoo_flixel/FlxDirector.kiss | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/hollywoo_flixel/ActorFlxSprite.hx b/src/hollywoo_flixel/ActorFlxSprite.hx index 795f376..47c80e8 100644 --- a/src/hollywoo_flixel/ActorFlxSprite.hx +++ b/src/hollywoo_flixel/ActorFlxSprite.hx @@ -3,6 +3,7 @@ package hollywoo_flixel; import kiss.Prelude; import kiss.List; import flixel.FlxSprite; +import hollywoo_flixel.FlxMovie; typedef AnimationArgs = { name:String, diff --git a/src/hollywoo_flixel/ActorFlxSprite.kiss b/src/hollywoo_flixel/ActorFlxSprite.kiss index fd12502..4fdf499 100644 --- a/src/hollywoo_flixel/ActorFlxSprite.kiss +++ b/src/hollywoo_flixel/ActorFlxSprite.kiss @@ -1,5 +1,10 @@ -(defNew [:String assetPath &opt frameWidth frameHeight :Map animations] +(prop :FlxStageFacing defaultFacing) + +(defNew [:String assetPath &opt frameWidth frameHeight :FlxStageFacing defaultFacing :Map animations] (super) + + (set this.defaultFacing (or defaultFacing Right)) + (if (and frameWidth frameHeight) (loadGraphic assetPath true frameWidth frameHeight) (loadGraphic assetPath)) diff --git a/src/hollywoo_flixel/FlxDirector.kiss b/src/hollywoo_flixel/FlxDirector.kiss index baf0e15..ae3cfd4 100644 --- a/src/hollywoo_flixel/FlxDirector.kiss +++ b/src/hollywoo_flixel/FlxDirector.kiss @@ -22,7 +22,8 @@ (method :Void showCharacter [:Character 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