Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Scaling by dragging handles now work

  • Loading branch information...
commit a9df345087be95d375769ff14c87683b6c40134b 1 parent 0494ada
Viktor Lidholt authored
Showing with 12 additions and 0 deletions.
  1. +12 −0 CocosBuilder/ccBuilder/CocosScene.m
View
12 CocosBuilder/ccBuilder/CocosScene.m
@@ -851,9 +851,21 @@ - (BOOL) ccMouseDragged:(NSEvent *)event
CGPoint deltaStart = ccpSub(nodePos, mouseDownPos);
CGPoint deltaNew = ccpSub(nodePos, pos);
+ // Rotate deltas
+ CGPoint anglePos0 = [transformScalingNode convertToWorldSpace:ccp(0,0)];
+ CGPoint anglePos1 = [transformScalingNode convertToWorldSpace:ccp(1,0)];
+ CGPoint angleVector = ccpSub(anglePos1, anglePos0);
+
+ float angle = atan2f(angleVector.y, angleVector.x);
+
+ deltaStart = ccpRotateByAngle(deltaStart, CGPointZero, -angle);
+ deltaNew = ccpRotateByAngle(deltaNew, CGPointZero, -angle);
+
+ // Calculate new scale
float xScaleNew = (deltaNew.x * transformStartScaleX)/deltaStart.x;
float yScaleNew = (deltaNew.y * transformStartScaleY)/deltaStart.y;
+ // Set new scale
[appDelegate saveUndoStateWillChangeProperty:@"scale"];
int type = [PositionPropertySetter scaledFloatTypeForNode:transformScalingNode prop:@"scale"];
Please sign in to comment.
Something went wrong with that request. Please try again.