# Shrink objects in runtime

For questions about using Classic.

### » Wed Jan 20, 2010 10:10 pm

Hey there.

I'm trying to shrink object so they fit in certain area of the layout.
Basicly if you would look at the .cap you see what i'm talking about.

If you make 25x25 array its should be ok. But if you would make 35x35 array it should shrink the boxes so they fit in the area that is fixed for them.
The methods that i have been using, well they are just making construct crashing so i dont have a clue how to do this.

Here is the file:
[url:2n1ou0az]http://www.internet.is/eski/shrink.cap[/url:2n1ou0az]
B
7
S
1
G
3
Posts: 66
Reputation: 1,651

### » Wed Jan 20, 2010 10:24 pm

There's actually a really simple formula for this. The formula for finding the proper size is:

AreaWidth / XObjectCount

Since the size of the area you're filling is 400, simply divide 400 by the amount of objects placed along the X axis to get the necessary width for your objects. The width can be used for the height as well, unless you want to allow rectangular areas, in which case you would set the height to:

AreaHeight / YObjectCount

I hope this helps.
Moderator
B
104
S
39
G
19
Posts: 1,584
Reputation: 18,167

### » Thu Jan 21, 2010 1:32 am

[quote="linkman2004":1j73f7o4]There's actually a really simple formula for this. The formula for finding the proper size is:

AreaWidth / XObjectCount

Since the size of the area you're filling is 400, simply divide 400 by the amount of objects placed along the X axis to get the necessary width for your objects. The width can be used for the height as well, unless you want to allow rectangular areas, in which case you would set the height to:

AreaHeight / YObjectCount

I hope this helps. [/quote:1j73f7o4]

The problem that i'm having is i want to scale the box down. This method works well but sometimes the boxes get streched out and then they look funky.
The boxes are default 16x16 but if the level is lets say 30x30 then i should be 400 / 30 = 13,3 per height and width.

I want to allow rectangular, like 35x15
B
7
S
1
G
3
Posts: 66
Reputation: 1,651

### » Thu Jan 21, 2010 1:51 am

I'd suggest using the box plugin instead of a sprite for the boxes. That not only allows you to scale the boxes without increasing the thickness of the edge, but it fixes the blurring associated with floating point sizes.

For rectangular areas, I'd suggest setting the height of the objects to that of the width, just so all of the boxes are square.
Moderator
B
104
S
39
G
19
Posts: 1,584
Reputation: 18,167

### » Thu Jan 21, 2010 2:28 am

[quote="linkman2004":3e0wyarp]I'd suggest using the box plugin instead of a sprite for the boxes. That not only allows you to scale the boxes without increasing the thickness of the edge, but it fixes the blurring associated with floating point sizes.

For rectangular areas, I'd suggest setting the height of the objects to that of the width, just so all of the boxes are square.[/quote:3e0wyarp]

mmm.. i cant make any changes on the box plugin...
I'm using sprites because i have animation when you click on the box and when you deselect it..

I'm real close to geting this, just trying to figure out how to use the OR and else commands.
Its confusing, when using OR and ELSE should i add it as a sub event ?
B
7
S
1
G
3
Posts: 66
Reputation: 1,651

### » Thu Jan 21, 2010 4:58 am

No, not a sub-event.

Or is used in the same condition block, like so:

[code:38us93hx]
+ Player is overlapping cheese
+ Or
+ Player is overlapping kangaroo
[/code:38us93hx]

The Else is a new event underneath the previous event. Using else automatically creates a "pipe" to the event above it. Like so:

[code:38us93hx]
+ Player is overlapping cheese
|
+ Else
[/code:38us93hx]

When you use Else, it should be a condition all by itself, since it is basically saying "whenever the above conditions aren't happening."
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

### » Thu Jan 21, 2010 10:38 pm

Dunno if this is fixed yet but Else used to bug out if you added subevents to it.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Return to Help & Support using Construct Classic

### Who is online

Users browsing this forum: No registered users and 0 guests