Skip to content

Commit

Permalink
update body
Browse files Browse the repository at this point in the history
  • Loading branch information
tyanmahou committed Dec 21, 2024
1 parent 5da7b99 commit 617e504
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Re-Abyss/app/components/Actor/Common/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ namespace abyss::Actor
s3d::Vec2 Body::getCenterPos() const
{
if (m_anchor == BodyAnchor::BottomCenter) {
return this->getOffsetedPos() - Vec2{ 0, m_sizePrev.y / 2.0 };
return this->getOffsetedPos() - Vec2{ 0, m_size.y / 2.0 };
} else if (m_anchor == BodyAnchor::TopCenter) {
return this->getOffsetedPos() + Vec2{ 0, m_size.y / 2.0 };
} else {
return this->getOffsetedPos();
}
Expand All @@ -350,6 +352,8 @@ namespace abyss::Actor
{
if (m_anchor == BodyAnchor::BottomCenter) {
return { m_pos + m_offset - Vec2{m_size.x /2.0, m_size.y}, m_size };
} else if (m_anchor == BodyAnchor::TopCenter) {
return { m_pos + m_offset - Vec2{m_size.x / 2.0, 0}, m_size };
} else {
return { m_pos + m_offset - m_size / 2, m_size };
}
Expand All @@ -358,6 +362,8 @@ namespace abyss::Actor
{
if (m_anchor == BodyAnchor::BottomCenter) {
return { m_prevPos + m_offsetPrev - Vec2{m_sizePrev.x / 2.0, m_sizePrev.y}, m_sizePrev };
} else if (m_anchor == BodyAnchor::TopCenter) {
return { m_prevPos + m_offsetPrev - Vec2{m_sizePrev.x / 2.0, 0}, m_sizePrev };
} else {
return { m_prevPos + m_offsetPrev - m_sizePrev / 2, m_sizePrev };
}
Expand Down
3 changes: 3 additions & 0 deletions Re-Abyss/app/components/Actor/Common/BodyAnchor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ namespace abyss::Actor
{
Center,
BottomCenter,
TopCenter,
CenterLeft,
CenterRight,
};
}

0 comments on commit 617e504

Please sign in to comment.