layering thing

For questions about using Classic.

Post » Thu Jul 16, 2009 3:36 pm

In MMF there was an object called the "layer object" that could do things like, sort all the objects/sprites according to a private variable - so you could make it so that the higher the variable then those objects would appear in front of objects with a lower value.

I tried doing something similar by:
always - start loop "sdf" 100 times

then if sprite variable = the loopindex "sdf", then send to front

but this seems to slow the game down a bit?
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Thu Jul 16, 2009 3:45 pm

Compare the layer the sprite's on, don't use a private variable; considering using families.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Thu Jul 16, 2009 4:56 pm

Isn't that what 'for each' (ordered) is for?
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Thu Jul 16, 2009 6:53 pm

Arima is right, something like:

+ For each Sprite order by Sprite('var')
-> Sprite: send to front

Then you can use any value you like to arrange the layering, eg. .x + .y, size, speed, anything!
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Fri Jul 17, 2009 10:36 am

thanks you guys are breathtaking. I thought that for each ordered thing would be useful one day.
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests