How do I prevent a sprite from scaling

Get help using Construct 2

Post » Mon Oct 19, 2015 4:14 pm

I have a background on a layer and a sprite on another.
I'm zooming in and out on the background layer with the mouse wheel, but I'd like to prevent the sprite from scaling.

I could set the scale rate of the layer the sprite is in into zero, but that does not maintain its position in relation to the zoomed layer.
To put it easier, imagine a transformation/rotation gizmo in a 3D application. You can zoom and pan the view, but the gizmo always maintains its position and size.
B
13
S
5
G
1
Posts: 116
Reputation: 1,805

Post » Mon Oct 19, 2015 4:24 pm

Just change the gizmo scale when you change the layer scale. You will have to reset the position too. Grab the gizmo's x and Y, and shove them into a variable. After the scale, then you can set position back to the gizmos X and Y.

Is the center not in the middle of the Gizmo?
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Mon Oct 19, 2015 5:05 pm

Thanks @jojoe

I tried scaling the gizmo down when i scale the layer up (and vice versa), like this:
Set Layer 1 scale to LayerScale(1)+0.002
Set Gizmo scale to LayerScale(1)-0.002

but unfortunately it doesn't work as expected. It keeps scaling up with the layer, just with a slower rate.
With this method though the position is maintained, so I don't need to do anything.

The other method is to set the scale rate of the layer to zero (which solves the scaling problem), but messes up its position. In this case I can do as you said: keep track of the gizmo's X and Y and position it. The problem is that the 2 layers (one scaled the other not) seem to have different coordinates after scaling. I'm guessing I have to use CanvasToLayer or LayerToCanvas but I can't really grasp what's happening
B
13
S
5
G
1
Posts: 116
Reputation: 1,805

Post » Mon Oct 19, 2015 5:21 pm

Why not put the gizmo on a layer that does not get scale, and then snap it to whatever object needs the gizmo after the scale? The gizmo would be unaffected by the scale, but might need to be re-positioned.
B
29
S
8
G
4
Posts: 767
Reputation: 5,985

Post » Mon Oct 19, 2015 5:35 pm

Thanks again @jojoe

I tried exactly what you said but as soon as I scale the layer, the position of the gizmo (which is on a layer with scale rate=0) becomes "relative".
I'm trying to re-position it on the object every tick, but it only moves exactly on the object's origin when the background layer scale goes back to 1.
I don't know how to explain it better and thanks again for your valuable help!

EDIT: Attached a capx to better demonstrate what I mean

dl.dropboxusercontent.com/u/14855413/ex1.capx
B
13
S
5
G
1
Posts: 116
Reputation: 1,805


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests