Precise resizing, restoring default size

For questions about using Classic.

Post » Mon Aug 30, 2010 10:56 pm

Hi, I'm sorta kinda new to Construct and I've been doodling quite a bit in it lately, but there's two things that've been bugging me for a while and I can't seem to find the solution either on the wiki or these forums.

The first is, is there a way to precisely change an object's dimensions, using % points of their current state? i.e. an object is 100x100 pixels, resize it to 50% of its original -> it's now 50x50 pixels. So far I've been using the object's size in pixels and manually deriving what the final size aught to be for width and height separately, but it'd be nice to know if there's an easier way to do this.

Secondly, is there some way to restore an object to its default size, i.e. the size of the actual frame in the animation editor? Once in a while my hand slips while I'm placing objects and I accidentally stretch one out of proportion. Generally I can just Undo it easily enough but if it somehow escapes my notice I don't know what to do besides re-make the entire object. I figured there's got to be an option for this but I can't seem to find it?

Thanks for any help :D
B
35
S
15
G
16
Posts: 268
Reputation: 10,711

Post » Tue Aug 31, 2010 1:27 am

A slightly hacky way would be to get the object's width/height first.

So

On (somevent)
set sprite1 width = sprite1.width/2
set sprite1 height = sprite1.height/2

This should halve its size. If you want a specific percentage, try multiplying by decimal fractions.
eg. 50% = 0.5, 10% = 0.1, 33% = 0.33

set sprite1 width = sprite1.width*0.5
B
2
G
2
Posts: 42
Reputation: 734

Post » Tue Aug 31, 2010 2:40 am

While Squish showed a quick solution, it is not suitable for all needs.

Imagine you would want to set the sprite's dimension to 50% and a few seconds later to 75%. Let's say the original dimensions were 100x100. Then we would want the sprite to first shrink to 50x50 and later grow to 75x75.

(height omitted)
1) width = width * 0.5 (the sprite is now 50x50)
2) width = width * 0.75 (the sprite is now 37.5x37.5)

You could keep track of when to grow and when to shrink, and calculating that 75% is 1.5 * 50% and therefore replace 2) with width = width * 1.5, but it gets more and more complex as you change the sizes.

An easier way is to use the expressions Get original width/Get original height. They always return the original initial values regardless of any changes to the size.

1) width = OriginalWidth * 0.5 (sprite is now 50x50)
2) width = OriginalWidth * 0.75 (sprite is now 75x75)
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Wed Sep 01, 2010 4:16 am

Gotcha, I guess that'll take care of that problem. Grats!

As to my second question, I guess it's just a matter of setting the object size to the dimensions of its 1st frame of the default animation. Guess I should've figured that out sooner instead of panicking :lol:

Thanks again for the help guys!
B
35
S
15
G
16
Posts: 268
Reputation: 10,711

Post » Wed Sep 01, 2010 1:19 pm

Hey, nice. I didn't notice that you can get original width/height.

Cheers for that Tula.


As an add on:
If you have non-default sizes to start with, you can store those at layout start into private variables.
Eg. On layout start
Set "origWidth" = sprite.width
Set "origHeight" = sprite.height
B
2
G
2
Posts: 42
Reputation: 734


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests