Skip to content

Commit

Permalink
Merge pull request #3049 from Ghabry/fix/flip
Browse files Browse the repository at this point in the history
Battle: Fix broken animation when the sprite is flipped
  • Loading branch information
fdelapena authored Jul 5, 2023
2 parents ba071e2 + 75aae4f commit a674efc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/battle_animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,9 @@ void BattleAnimation::DrawAt(Bitmap& dst, int x, int y) {
continue;
}

SetX(invert ? x - cell.x : cell.x + x);
SetX(cell.x + x);
SetY(cell.y + y);
int sx = cell.cell_id % 5;
if (invert) sx = 4 - sx;
int sy = cell.cell_id / 5;
int size = animation.large ? 128 : 96;
SetSrcRect(Rect(sx * size, sy * size, size, size));
Expand Down
5 changes: 2 additions & 3 deletions src/sprite_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ void Sprite_Actor::Update() {
animation->SetVisible(IsVisible());
}

const bool flip = battler->IsDirectionFlipped();
SetFlipX(flip);
SetFlipX(battler->IsDirectionFlipped());
}

void Sprite_Actor::SetAnimationState(int state, LoopState loop, int animation_id) {
Expand Down Expand Up @@ -268,7 +267,7 @@ void Sprite_Actor::DoIdleAnimation() {

void Sprite_Actor::OnBattlercharsetReady(FileRequestResult* result, int32_t battler_index) {
SetBitmap(Cache::Battlecharset(result->file));
SetSrcRect(Rect((battler->IsDirectionFlipped() ? 96 : 0), battler_index * 48, 48, 48));
SetSrcRect(Rect(0, battler_index * 48, 48, 48));
}

void Sprite_Actor::Draw(Bitmap& dst) {
Expand Down
8 changes: 3 additions & 5 deletions src/sprite_weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ void Sprite_Weapon::Update() {

SetSrcRect(Rect(frame * 64, battler_animation_weapon->weapon_index * 64, 64, 64));

const bool flip = battler->IsDirectionFlipped();
SetFlipX(flip);
SetFlipX(battler->IsDirectionFlipped());
}

void Sprite_Weapon::SetWeaponAnimation(int nweapon_animation_id) {
Expand Down Expand Up @@ -125,9 +124,8 @@ void Sprite_Weapon::CreateSprite() {

void Sprite_Weapon::OnBattleWeaponReady(FileRequestResult* result, int32_t weapon_index) {
SetBitmap(Cache::Battleweapon(result->file));
const bool flip = battler->IsDirectionFlipped();
SetFlipX(flip);
SetSrcRect(Rect((flip ? 128 : 0), weapon_index * 64, 64, 64));
SetFlipX(battler->IsDirectionFlipped());
SetSrcRect(Rect(0, weapon_index * 64, 64, 64));
}

void Sprite_Weapon::Draw(Bitmap& dst) {
Expand Down

0 comments on commit a674efc

Please sign in to comment.