set scale sprite from small to big?

Get help using Construct 3!

Post » Mon Aug 07, 2017 3:03 am

how to add 1 to size of sprite every 1 second or tick,
like the sprite increase from small to big?
B
7
S
2
Posts: 22
Reputation: 569

Post » Mon Aug 07, 2017 10:20 am

Here's a project that shows you how, it is very simple by the way. All you do is create an instance variable for the sprite, then every second add to the instance variable the size that you want. Last but not least, every tick | your sprite -> set size to Self.size (the instance variable we created, Self means that it is a variable of a sprite)

Project download:
https://mega.nz/#F!u8tUzS5J!tjxPKv5_vQawD8HY77MKhQ
Burry me with my empty hands sticking out the ground, so that all can see, that the one who had the world on his hands, died with them empty.
B
19
S
4
G
4
Posts: 133
Reputation: 3,068

Post » Mon Aug 07, 2017 12:24 pm

7Winter answered your question as exactly as possible.

But lets dive a little deeper in the problem. And then i have to start with putting your question in question.
Size(In C2 language) is (indeed) width & height combined. I suppose that when you want to add 1 to the size, that you want to add 1 to the height and 1 to the width. That will only work for square objects. And, if you keep adding 1 (a constant), the rate of the scaling will be different on a slow machine (compared to a fast device). And, obvious, adding 1 to a sprite with size 1000 pixels gives a total different perception than adding 1 to a sprite with a width of 1 pixel. (in the last case it just doubles, in the first case it is even hard to see a difference).

So, allow me to dive into this in steps. To start with, it easier to use 'scale' in stead of 'size'.
https://www.dropbox.com/s/k19xf8aa2rj8y ... .capx?dl=0

But this has still the problem that the scaling rate depends on the FPS linked to the device. We solve that with using dt. You should always use dt if you do something per tick.
https://www.dropbox.com/s/5dteatrx1mg73 ... .capx?dl=0

To be complete lets do the same with 'size'.
https://www.dropbox.com/s/so6rk61cc2phh ... .capx?dl=0

Now both 'solutions' still have a 'perception' problem. The rate is unnatural. It seem to scale faster when it is small and slower when it is big. Lets do something about that. Here you see 2 sprites grow, so you can compare. I am not smart enough to do that using 'size'. So i fall back to using 'scale'.
https://www.dropbox.com/s/qmbl1mp66lmr3 ... .capx?dl=0

Or, lets even do it even 'supernatural'.
https://www.dropbox.com/s/h5u1d4yffaiwp ... .capx?dl=0
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I...?

Who is online

Users browsing this forum: tarek2 and 1 guest