Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pet could not be selected properly if flipped #70

Merged
merged 1 commit into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/Engine/SpriteAnimator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ class SpriteAnimator
return pSheet == nullptr || isEnd;
}

bool isMouseOver(Vec2i cursorPos)
bool isMouseOver(Vec2i cursorPos, bool flip)
{
if (flip)
cursorPos.x = (pSheet->getWidth() / pSheet->getTileCount()) - cursorPos.x - 1;

cursorPos.x += indexCurrentAnimSprite * pSheet->getWidth() / pSheet->getTileCount();
return pSheet != nullptr ? pSheet->isPixelOpaque(cursorPos) : false;
}
Expand Down
2 changes: 1 addition & 1 deletion include/Game/Pet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class Pet
floor(datas.cursorPos.x / (float)(datas.scale * spriteAnimator.getSheet()->getSizeFactor()))),
static_cast<int>(
floor(datas.cursorPos.y / (float)(datas.scale * spriteAnimator.getSheet()->getSizeFactor())))};
return spriteAnimator.isMouseOver(localCursoPos);
return spriteAnimator.isMouseOver(localCursoPos, !datas.side);
}
else
{
Expand Down