# How do I Make a sprite larger as it gets closer?

Get help using Construct 2

### » Sun Jan 04, 2015 8:02 pm

I need a sprite to get bigger as it gets closer to the bottom of the layout, simulating a car driving towards you from the horizon. Sort of a 3d illusion.

I've tried some stuff, but its clearly wrong lol.

Every .1 seconds --> set pos to Enemy.y
pos < Enemy.y --> set size to (Enemy.Width + 1, Enemy.Height + 1)

This works somewhat, but they don't ever stop growing really, and they grow at a bad rate. Its just not right lol. I'm sure there is a simple way to do this, or some math to apply. Any suggestions?

Thanks.
B
4
Posts: 5
Reputation: 212

### » Sun Jan 04, 2015 8:07 pm

Just do something like: Width < LargestSizeYouNeed ==> Width=Width+dt*128 <== adjust this for speed. Height = Width (if it's not square adjust this with a ratio).
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

### » Sun Jan 04, 2015 8:45 pm

Yeah, but then they just grow no matter what, not just when they approach the bottom of the layout. Unless im missing something? How do i do this with regard to the Y co-ordinate?
B
4
Posts: 5
Reputation: 212

### » Sun Jan 04, 2015 9:03 pm

If it's non-interactive just add a downward movement of some sort, if not do something like - Every tick: Width = DesiredWidth * Sprite.Y/LowestYItCanGet <== This is then a ratio between the current position and total height. So, for example, if your layout is 640 tall and the car at 640 should be 256 pixels wide and currently it is at 320 or so you do something like: Every tick Width = 256 * Sprite.Y/640 - which will be equal to 0.5, so your car will be 128px wide.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

### » Sun Jan 04, 2015 9:13 pm

Yeah that's what i was going for. Thanks!
B
4
Posts: 5
Reputation: 212