Smooth layout scale?

Get help using Construct 2

Post » Thu Feb 13, 2014 5:33 pm

Hi all

Is there a way to make Smooth layout scale?

Example:

On start of layout........Set layout scale to 1

player on collision with object.....Set layout scale to 0,8

If i use this event it's not smooth.

Any one can help please?

Best Regards
B
7
S
1
Posts: 65
Reputation: 586

Post » Fri Feb 14, 2014 8:41 am

Sorry
But any one can help
B
7
S
1
Posts: 65
Reputation: 586

Post » Fri Feb 14, 2014 8:45 am

variable scaler = 1


every tick
system set layer scale "Background"
lerp(LayerScale("Background"), scaler, 0.01)



would you change the variable scaler at any one time to 2, it would gradually smooth the scale of the layer called "Background" to 2.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Fri Feb 14, 2014 9:10 am

Thanks alot

But i want to change all the layout scale not layer

If i set the layout to 1 and then when player on collision with object .... set layout scale to 0.8 ... it work find but not smoothly.
B
7
S
1
Posts: 65
Reputation: 586

Post » Fri Feb 14, 2014 9:39 am

oi, ....


scaler = 0.8

every tick
set layoutscale lerp(1,scaler,0.1)lennaert2014-02-14 09:41:41
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Fri Feb 14, 2014 1:35 pm

Sorry i'm confuse

What the difference between your code and:
Player on collision with A.......Set layout scale to 0.8

And how can this help to get smooth zoom out?
B
7
S
1
Posts: 65
Reputation: 586

Post » Sat Feb 15, 2014 1:21 am

He is telling you don't set the scale on collision. On collision set a variable and then when that variable matches whatever you get it to, set layoutscale to lerp(layoutscale, 0.8, 3*dt) to have it smoothly move between the current layout scale and 0.8 scale.
B
103
S
38
G
19
Posts: 962
Reputation: 17,996

Post » Sat Feb 15, 2014 1:49 am

@slanw, `lerp()` is a system expression that allows you to smoothly change from one value to another. If you read the definition for it, then at first it may sound a little complicated, but basically, it allows for exactly what you are looking for.


From the Manual:
"lerp(a, b, x) Linear interpolation of a to b by x. Calculates a + x * (b - a)."
B
20
S
4
G
1
Posts: 185
Reputation: 2,563

Post » Sat Feb 15, 2014 7:46 am

Last edited by Yann on Sun Sep 14, 2014 7:13 pm, edited 2 times in total.
B
67
S
22
G
14
Posts: 1,485
Reputation: 16,536

Post » Sat Feb 15, 2014 1:11 pm

Thank's alot all for the help

And yann capx is awesome

This is nice example for smooth zoom in and out

Best regards to all
B
7
S
1
Posts: 65
Reputation: 586

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 11 guests