Skip to content

Commit

Permalink
prevent scale reset
Browse files Browse the repository at this point in the history
  • Loading branch information
altalk23 committed Jul 18, 2024
1 parent fe1717d commit b63b499
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## v0.3.2-alpha
* Added Custom Keybinds as a dependency for all platforms
* Prevent scale resetting by not generating tiny scaled objects (< 0.001)

## v0.3.1-alpha
* Fixed the touch prio in support popup
Expand Down
8 changes: 5 additions & 3 deletions src/util/EditorUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ void EditorUtilities::addRectangle(cocos2d::CCPoint const& p1, cocos2d::CCPoint
auto const center = (p1 + p3) / 2.0f;
auto const angle = std::atan2(p2.y - p1.y, p2.x - p1.x);

auto object = LevelEditorLayer::get()->createObject(SQUARE_OBJECT_ID, center, false);
object->setRotation(-angle * 180.0f / M_PI);

auto scaleX = p1.getDistance(p2) / SQUARE_OBJECT_SCALE;
auto scaleY = p1.getDistance(p4) / SQUARE_OBJECT_SCALE;

if (scaleX < 0.001f || scaleY < 0.001f) return; // Prevent scale reset

auto object = LevelEditorLayer::get()->createObject(SQUARE_OBJECT_ID, center, false);
object->setRotation(-angle * 180.0f / M_PI);

object->updateCustomScaleX(scaleX);
object->updateCustomScaleY(scaleY);

Expand Down

0 comments on commit b63b499

Please sign in to comment.