[SOLVED] How do I make an object scale based on Y?

Get help using Construct 2

Post » Sun Apr 13, 2014 5:28 pm

Hi everyone,

I'm trying to make a sprite scale up in size as it goes up in Y value on the layout (like trying to simulate just a little bit of perspective for an adventure game). I know the answer must be simple, but my mind must be even simpler because I have a really hard time trying to figure this out. Any help would be really appreciated. Thanks!
Last edited by nateneurotic on Mon Apr 14, 2014 2:37 am, edited 1 time in total.
B
6
Posts: 3
Reputation: 314

Post » Sun Apr 13, 2014 7:21 pm

Try this:

Create instance variables : PlayerWidth & PlayerHeight and set them to original size

Then in event's

-Is Player moving, every tick :
---set player size: Width to: varPlayerWidth + (Y/n), Height to: varPlayerHeight + (Y/n),

where "n" is a number you will divide Y with so you won't get extremely huge character.

You could try using scaling too, which will probably work better, but can't remember how to do it from top of my head.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
85
S
27
G
21
Posts: 1,969
Reputation: 19,167

Post » Sun Apr 13, 2014 7:49 pm

Try "Set Scale to (1/480)*sprite.Y"

480 being the set screen height.

Or "Set Scale to 0.5+(1/480)*sprite.Y"

so that mid screen is scale 1, original size.
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Post » Sun Apr 13, 2014 8:35 pm

Paradox wrote:Try "Set Scale to (1/480)*sprite.Y"

480 being the set screen height.

Or "Set Scale to 0.5+(1/480)*sprite.Y"

so that mid screen is scale 1, original size.


Wouldn't be better to use system's ScreenHeight instead of 480?
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
85
S
27
G
21
Posts: 1,969
Reputation: 19,167

Post » Sun Apr 13, 2014 9:01 pm

I simplified it as much as possible so that it was easier to understand and complicate back up to the actual situation.

1/480 is quicker to comprehend you are dividing the screen into a fractional size that you use as the steps in size. Avoiding all the complications like parallax, window height, and fluctuating numbers that cause flickering when sitting still.

(also why I left 0.5 out of the 1st example.)

(ScreenHeight is actually a Browser expression: Retrieve the dimensions of the entire device screen. This is the complete display area available to the operating system.)
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Post » Mon Apr 14, 2014 2:33 am

Thanks guys, both of you were a big help! Paradox, your solution is the one that seems to work best, but I appreciate seeing multiple ways of getting the job done, and it all helps me understand expressions a little more.

Update, I got things working just how I wanted! I didn't need the scaling to go all the way from 1 to zero, so I made some adjustments to make sure the scaling wouldn't be so drastic from bottom to top of the layer.

Here's what I got going
My layout is 720 pixels tall. I also wanted movement speed to scale down with the PlayerAnimation size too, so the illusion wouldn't be broken

System: Every Tick
-Set scale to (1/2160)*(PlayerAnimations.Y + 1440)
-Set 8Direction Maximum Speed to (300/2160)*(PlayerAnimations.Y+1440)

I found out that if I increased the denominator to 3 times the size of my layout, and added the remainder back to the PlayerAnimations.Y, I could keep the Y(720) yielding a 1 scale, while having the Y(0) yield me a .6667 scale.

Once again, thanks for all the help guys!
B
6
Posts: 3
Reputation: 314

Post » Mon Apr 14, 2014 10:08 pm

Great to hear! I should have thought about the speed scaling, I bet that looks good.
It's always gets a lot more complicated once you squeeze it in what you are doing.
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Post » Tue May 13, 2014 4:50 pm

Here's what I got going
My layout is 720 pixels tall. I also wanted movement speed to scale down with the PlayerAnimation size too, so the illusion wouldn't be broken

System: Every Tick
-Set scale to (1/2160)*(PlayerAnimations.Y + 1440)
-Set 8Direction Maximum Speed to (300/2160)*(PlayerAnimations.Y+1440)

I found out that if I increased the denominator to 3 times the size of my layout, and added the remainder back to the PlayerAnimations.Y, I could keep the Y(720) yielding a 1 scale, while having the Y(0) yield me a .6667 scale.


Thanks for posting. This is exactly what I am looking for. It gives me a 100% sized sprite at the bottom of the screen and not too tiny at the top.
The trouble is that I don't quite understand how you worked it out and I would really like to.
If you or anyone else could explain this in an artist friendly way I would very much appreciate it. :)
B
9
S
3
G
1
Posts: 23
Reputation: 828

Post » Sun May 25, 2014 12:44 am

I'd really like to know as well.
B
11
S
2
Posts: 5
Reputation: 1,309


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, sublimate, Yahoo [Bot] and 10 guests