Scale/Resize independent of origin?

Discussion and feedback on Construct 2

Post » Sun Dec 04, 2016 11:38 pm

I have my play animations all with their origin set to centre, is there a way of scaling the height of an object without it using the origin as the scale point? I can't change the origin to the bottom where it needs to be for the height resize to look right, so can I make C2 resize the height as if the origin is at the bottom?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Mon Dec 05, 2016 1:26 am

B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Mon Dec 05, 2016 5:14 pm

R0J0hound wrote:You could use the math here:
viewtopic.php?f=147&t=115814&p=835386&hilit=scale+center#p835386

If I use the math there in the scale expression, won't it still scale to the origin, as C2 does that by default, doesn't it? Or does this need to go somewhere else?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Mon Dec 05, 2016 6:31 pm

Try it. The math will make it scale from (centerx, centery) regardless where the origin on the sprite is.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Mon Dec 05, 2016 9:48 pm

R0J0hound wrote:Try it. The math will make it scale from (centerx, centery) regardless where the origin on the sprite is.

So, do I need to make centerY and centerX globals? What numbers should I set them to?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Mon Dec 05, 2016 10:24 pm

You could also create a second image point and use that as the reference when you're scaling.

Or if you didn't want to deal with creating a second image point, and want to scale from the center bottom, you could scale from sprite.x, sprite.y+sprite.height/2.
B
77
S
43
G
24
Posts: 525
Reputation: 20,580

Post » Tue Dec 06, 2016 12:23 am

digitalsoapbox wrote:You could also create a second image point and use that as the reference when you're scaling.

How do you do this? I can make image points, I just have no idea how to reference it with scaling?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Tue Dec 06, 2016 12:32 am

Using the expressions:
Sprite.ImagePointX(point)
Sprite.ImagePointY(point)

Replace "point" with either the index of the of the image point like 0 for the origin, 1 for the first image point, 2 for the second,... and so on.
...or you can use the name of the image point.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Tue Dec 06, 2016 2:23 pm

R0J0hound wrote:Using the expressions:
Sprite.ImagePointX(point)
Sprite.ImagePointY(point)

Replace "point" with either the index of the of the image point like 0 for the origin, 1 for the first image point, 2 for the second,... and so on.
...or you can use the name of the image point.

So, for instance, if I want to squash a sprite's height, do I use that in the set height expression?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Tue Dec 06, 2016 3:37 pm

Only "scale" is used in the set height expression. It's actually the same as if you squished the height with it scaled around the origin. The only thing that changes when you scale from a different point is the object needs to be moved.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Darknessed and 3 guests