Optimizing Containers

For questions about using Classic.

Post » Thu Oct 07, 2010 2:01 pm

Hi. I am using familes and containers to glue objects and character in my game. I have two families for now: cBase and cSprite, one for collision and others calcs and the other the sprite itself. Here how it looks.



Actually works well. But if there are many sprites in screen, and there is only one character moving, it is a waste of performance to move all sprites to their own base. So what I want is move sprites if only the base is moving. I have done this, but it does not work, because it picks all sprites in the escene. I have tried using For each loops too.

B
30
S
15
G
10
Posts: 285
Reputation: 7,144

Post » Thu Oct 07, 2010 2:18 pm

I've been wrangling with this issue a bit as well - tbh, I think the amount of time spent checking the variables for which ones to place might be the same as simply placing them all.

Are you sure the variables are set correctly? Try adding an event like:

always set base sprite opacity to 50
if moving variable = 1, set base sprite opacity to 100
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Fri Oct 08, 2010 5:16 am

Did you try debugging that value? perhaps it's 1 in all sprites
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Fri Oct 08, 2010 8:20 am

I use this value for other tasks without problems. Anyway, if the value is 1 in all sprites, the problem is that each cSprite would be positioned to each own cBase, and not all of them to the same. In the first example, only two objects are picked as expected, but in the second one, all sprites in the scene. If I am not wrong, when you pick or use an sprite in a container, automatically the rest is picked too.
B
30
S
15
G
10
Posts: 285
Reputation: 7,144

Post » Fri Oct 08, 2010 8:30 am

Well, i have found the problem. It does not work with families. I have replaced, families with sprites and it works. So this is a bug or a contruct limitation?
B
30
S
15
G
10
Posts: 285
Reputation: 7,144

Post » Fri Oct 08, 2010 2:33 pm

Ah, yeah, I think it's a limitation. I got around it by using the object pairer instead - I use for each 'family', create a shadow and pair them.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Fri Oct 08, 2010 9:57 pm

[quote="Arima":32ywd1km]Ah, yeah, I think it's a limitation. I got around it by using the object pairer instead - I use for each 'family', create a shadow and pair them.[/quote:32ywd1km]

Interesting, never thought about using the pairer with families.
Thanks for the info.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Sat Oct 09, 2010 9:50 am

Well I can not understand at all the object pairer. How can I pair the two objects within a container? I have downloaded David's object pairer example ([url:1ifj2d7n]http://www.scirra.com/forum/viewtopic.php?f=16&t=2669[/url:1ifj2d7n]), but he pairs, when an object is created, and construct automatically picks the the object. In my case, the objects and containers are created.
B
30
S
15
G
10
Posts: 285
Reputation: 7,144

Post » Sat Oct 09, 2010 10:28 am

Well, I have it working. But the same problem again, it does not work with families. If I create objects to pair, I can not pick pairs with families :(
B
30
S
15
G
10
Posts: 285
Reputation: 7,144


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests