How do I get the scale of a sprite?

Get help using Construct 2

Post » Thu Jan 22, 2015 8:18 pm

You can set the scale of an individual sprite, but I want to make a sprite shrink over time by referencing the sprites current scale. However, I do not see any scale expressions listed.
For example: On Timer"Shrink", set scale to sprite.scale-0.2
Is this possible, or do I need to maintain a separate variable to track the sprite's current scale?
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Thu Jan 22, 2015 8:22 pm

Why not use size - as in width and height?
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Thu Jan 22, 2015 8:51 pm

Yeah, there is no scale expression, as you can't get scale in reverse if the width is different than the height.
A variable is the only way to go, but it also renders the scale action pointless.
Image ImageImage
B
168
S
50
G
169
Posts: 8,280
Reputation: 108,189

Post » Fri Jan 23, 2015 1:32 am

@Somebody Because it's fussing with two expressions instead of one, and there's extra math involved if you want to change size via percentage change, and you have to store two variables to hold the original size data as well. It's just plain clunky. Thank you though. The built in scale system is quite nice, it is simply lacking when you want to read the current scale setting is all. (IMHO)
@newt I don't quite understand your "scale in reverse" comment, please elaborate a little?
Also:>"A variable is the only way to go, but it also renders the scale action pointless."
Do you mean the action is pointless because we have a redundant variable? Because you still have to use the set scale action to make the sprite's scale actually change. It's just a hassle to not be able to read an objects current scale, thus the need for a somewhat redundant variable to track the current scale.
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Fri Jan 23, 2015 2:52 am

You make a variable called myscale, multiply the width and the height by that number.
You would then know what the scale is.
The system scale is what is now redundant.
Image ImageImage
B
168
S
50
G
169
Posts: 8,280
Reputation: 108,189

Post » Fri Jan 23, 2015 2:12 pm

@newt Oh, I see where you were going. I was thinking of using a variable that simply gets changed anytime the scale gets changed so that there would be some way of reading the current scale. Thanks for explaining that.
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Fri Jan 23, 2015 2:42 pm

@newt Ok, I just discovered something new: A scale of 1 makes the sprite the size of the *original image*. So if in the editor you shrank a 64x64 sprite down to 32x32 and then at runtime set scale to 1, that sprite would pop back to 64x64. I thought it would go back to the size set in the editor. Live and learn. I think I will do what you suggest, since many of my sprites are not the same size as the original image. Thanks again.
B
11
S
4
G
1
Posts: 159
Reputation: 1,803


Return to How do I....?

Who is online

Users browsing this forum: facecrime, odiusfly and 15 guests