diff --git a/changelog.md b/changelog.md index 4a78240..6b05e26 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/src/util/EditorUtilities.cpp b/src/util/EditorUtilities.cpp index 91d9a40..7e83182 100644 --- a/src/util/EditorUtilities.cpp +++ b/src/util/EditorUtilities.cpp @@ -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);