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

Get help using Construct 2

Post » 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
8
S
2
Posts: 22
Reputation: 548

Post » 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
19
S
8
G
3
Posts: 429
Reputation: 3,972

Post » 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
19
S
8
G
3
Posts: 429
Reputation: 3,972

Post » Fri May 26, 2017 6:56 pm

Thanks a lot @mekonbekon . :)
B
8
S
2
Posts: 22
Reputation: 548

Post » Sat May 27, 2017 7:55 pm

@khelaghor

You're welcome :)
B
19
S
8
G
3
Posts: 429
Reputation: 3,972


Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948 and 63 guests