Zoom sprite to 100%

Get help using Construct 2

Post » Mon Jan 13, 2014 2:29 am

@burvey re: your capx, if the sprite is not square it will distort. The aspect ratio of width and height cannot increment at the same rate.

my sprite was 100x60 and grew distorted (flat looking) and then when it approached full size it finally stretched out to normal, but the transition is not what the OP is talking about.

I'm still looking for the best way to do this.. probably scale? If I find out I will post it here.
B
97
S
32
G
15
Posts: 1,198
Reputation: 16,178

Post » Mon Jan 13, 2014 2:38 am

@jobel I was the OP ;)

Try @JJList solution above. It worked well for me.
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,986

Post » Mon Jan 13, 2014 2:42 am

sorry! I meant to link that to @JJList

I download the capx link...
B
97
S
32
G
15
Posts: 1,198
Reputation: 16,178

Post » Mon Jan 13, 2014 4:02 am

this works..

[QUOTE=R0J0hound] Hi,
I don't mean to step on toes but unfortunately Sprite doesn't have a scale expression. So here are the steps to get the effect you want.

1. Add an instance variable to your sprite, call it "myscale" and give it an initial value of 0.1.

2. Add an event with the "compare instance variable" condition and set it up as follows:

[code]Sprite: myscale<1.0
---> Sprite: add 1.0*dt to myscale
---> Sprite: set scale to myscale[/code]
Note, the first action is the "add to" action under "instance variables" and the 2nd action is "set scale" under "size & position".

This will need some tweaking to make it happen in one second. As it is now the expression 1.0*dt can be read as 1 per second, but we're going from 0.1 to 1.0 in a second, or just 0.9 in a second. So it should be like this:
[code]Sprite: myscale<1.0
---> Sprite: add 0.9*dt to myscale
---> Sprite: set scale to myscale[/code]

Another thing you can deal with if you like is what I like to call over shooting. With this event the end scale will likely be a bit more than 1.0. You can use the min() expression to limit the highest value to 1.0 and set up your event like this:
[code]Sprite: myscale<1.0
---> Sprite: set myscale to min(self.myscale + 0.9*dt, 1.0)
---> Sprite: set scale to myscale[/code]

As a final note you can make the duration longer or shorter by tweaking the dt expression.
half second:
2*0.9*dt
two second:
0.5*0.9*dt[/QUOTE]
B
97
S
32
G
15
Posts: 1,198
Reputation: 16,178

Post » Mon Jan 13, 2014 2:18 pm

You only need one variable and the known aspect ratio if you want to scale them consistently and absolutely and avoid scale.

If say your object is 16:9 ratio, and you were scaling it to 10x -

width=Lerp(self.width,self.width*10,0.5)
height=(width/16)*9

Or

height=width*0.5625


Image
B
27
S
9
G
5
Posts: 488
Reputation: 11,948

Previous

Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Nicolas951, tarek2 and 13 guests