# How do I scale an image depending on its Y position?

Get help using Construct 2

### » Fri May 26, 2017 1:46 pm

Message: khelaghor can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Hi, I'm building a soccer juggling game. I'm building it in top down view.So, for making kinda 3D effect I want to scale the ball according to its Y position. When its in the top of the screen it'll have scale 1 and when it'll decrease its scaling when its going downward. Here's the URl of the current state. https://soccerjuggle.netlify.com/. Press Z to juggle left feet and X to right feet. Thanks in advance for helping.
B
9
S
3
Posts: 28
Reputation: 735

### » Fri May 26, 2017 2:37 pm

@khelaghor

Add an instance variable to the ball called Ymax and give this the highest Y value that the ball reaches (e.g. if you kick the ball at Y= 400 then Ymax = 400)
Add an instance variable to the ball called scaleFactor and give this the value the maximum increase by which you want the ball to scale (e.g. if you want the ball to scale to 1.5 its size then scaleFactor = 0.5)

Every tick set ball scale to 1+(1-ball.Y/ball.Ymax)*ball.scaleFactor
B
24
S
9
G
4
Posts: 515
Reputation: 4,472

### » Fri May 26, 2017 2:42 pm

@khelaghor

An extra tip: to enhance the sense of depth add a ball shadow sprite that scales at the same rate as the ball and matches the ball's X value and Ymax value. Fade out the shadow based upon the ball's current scale (bigger scale, more faded shadow)
B
24
S
9
G
4
Posts: 515
Reputation: 4,472

### » Fri May 26, 2017 6:56 pm

Thanks a lot @mekonbekon .
B
9
S
3
Posts: 28
Reputation: 735

### » Sat May 27, 2017 7:55 pm

@khelaghor

You're welcome
B
24
S
9
G
4
Posts: 515
Reputation: 4,472