Optimizing Containers

This forum is currently in read-only mode.
  • 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.

    <img src="http://dl.dropbox.com/u/472186/Construct/Forums/Irudiak/containerPicking1.png">

    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.

    <img src="http://dl.dropbox.com/u/472186/Construct/Forums/Irudiak/containerPicking2.png">

  • 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

  • Did you try debugging that value? perhaps it's 1 in all sprites

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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?

  • 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.

  • 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.

    Interesting, never thought about using the pairer with families.

    Thanks for the info.

  • 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 (http://www.scirra.com/forum/viewtopic.php?f=16&t=2669), but he pairs, when an object is created, and construct automatically picks the the object. In my case, the objects and containers are created.

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)