0 Favourites

Group Objects

  • I want to select three different objects and perform the three of them the same event.

    How can I group all selected object just to create on event for all of them?

  • same like before, Add Event -> System -> ForEach -> Choose Object to create an event for all of them.

  • Three completely different objects rather than three instances of one object?

    What xeed said will work for the latter, but for the former you'll have to wait for a new feature called "families" that's going to be implemented soon. That'll allow you to group a bunch of objects under one label and affect all of them at the same time.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • sorry didnt read "different". so you are right, i am waiting for families (classes) feature too.

  • im waiting too for 'families' :)

  • I was thinking a (somewhat difficult) way would be to create one Sprite to represent all objects (that will need to be selected together), but put different "objects images" as different animation in the same sprite. When objects are placed at start of level or whatever, you tell each placed sprite what animation (or object) it is, then set each variable for that object depending on what it is.

    Then later when you need to select the multiple objects, you select the single sprite (which is acting like a family here) with extra condition to see which animation (object) it is...

    Of course if the animations are the core of the sprite, you may loose something here :)

    Does that make sense, or would that work?   I used that type of method on Classic one time and it worked great...

  • I know what you mean. The problem then would be that you want your objects to have different variables, health, damage etc... but still share that same base behaviour.

    The code you would need to make up for that might take up the same time and space as just coding many objects from scratch.

    Ive spent so many hours copying, pasting, editing to get around families but at the end of the day my code was so long that it was eating too much of the available space for the game.

    (10mb) if you hope to put it into the chrome store :(

  • Zetar is right, using one object is the way to go. If they are really that different (different variables, different behavior) it's weird that you would want to do the same thing with all of them. But still, you just have to put all these variable in this object (hp and damages could be the same variables it often represent something similar)

    if they share different behavior you often can deactivate behavior on a per object basis.

    So yeah, you then just need something like For instance

    Mouse: On Left click
       -> Object: set X to 100

    And all of you objects will move in position

    If you want one object to do something on this object can do

    Object: animation frame = 2
       -> Object: deactivate Bullet behavior
       -> Object: Activate 8 dir behavior

    Only the object with the proper animation frame will move

    If you use animation frames, you won't be able to have specific animation per object. But it can be overcome, if you use different animation instead of different animation frame, you will then compare the animation name.

    It will always be easier than copy pasting.

    It's what I use when I want to emulate families

  • You say is much better than I, Yann <img src="smileys/smiley42.gif" border="0" align="middle" /> I created a sort of Life simulator with multiple creatures as one sprite in Classic. (Attackers, grazers, ect...) I just added the extra lines of variables for all creatures, which weren't used in some creatures. I was able to get around the animations. (I never finished that project though <img src="smileys/smiley6.gif" border="0" align="middle" /> It is nice to have instance IDs now!!!!

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