Group objects

0 favourites
  • 7 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • In my game i have large spacehips, made from several parts from the same sprite.

    Some ships have +30 parts, when i need to explode tem, How do i aply to a group oficial objects ?

  • Container is probably what you're looking for. Put all the parts of the spaceship in a container of one object.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For what i have see container will not work... since i have the same object used in several diferent ships..., i will have to create a diferent sprite for each.

    As i said i have a sprite named mothership.. that has diferent frames.. each frame is a diferent part of the ship.. so i use the same object (sprite), for all the motherships.

    Maybe im using diferent the container..

  • Cant you just use an instance variable to identify which ship you are targeting?

    Give the Mothership sprite an instance variable "UsedForShip"

    then

    when you create the ships populate the instance variable for the individual instances with the name of the ship being used for.

    then when you want to explode

    for Mothership001

    All Mothership sprites > with instance variable "UsedForShip" = "Mothership001" > make explode

    for Mothership009

    All Mothership sprites > with instance variable "UsedForShip" = "Mothership009" > make explode

  • That is one way for do it...

    thanks

  • For what i have see container will not work... since i have the same object used in several diferent ships..., i will have to create a diferent sprite for each.

    As i said i have a sprite named mothership.. that has diferent frames.. each frame is a diferent part of the ship.. so i use the same object (sprite), for all the motherships.

    Maybe im using diferent the container..

    As i said before. i still dosent understand what containers do, basicaly they are very similar to families, if there was a way to group objects that are from same sprite but diferent ids, to a larger object (container) so that i can apply simplke things like destroy to all of them instead of pick object by id for each one of them.

    Some of my ships in my game has 78 parts.

  • No, containers are not similar to families at all!

    You can combine different object into a container, for example sprite+text+particles.

    Container holds instances of these objects, only 1 instance of each object per container.

    For example, you can have your main Spaceship sprite, Thruster sprite, TrusterFlame particles, MainWeapon sprite, HealthBar 9patch. Add all these objects into one container.

    When you create a new Spaceship in runtime, all instances of other objects from the container (Thruster, MainWeapon etc.) will be created automatically. You will only need to position them properly and pin if needed.

    If you create 10 ships like that, you'll basically have 10 containers.

    (If you create Spaceships and all other sprites from the container manually in editor, you need to do be careful to add them in order. Otherwise you might end up with different objects attached to wrong spacehips.)

    When you destroy a Spaceship, all instances of other objects from the container will be destroyed automatically.

    If you pick one object instance in an event, you can reference all other objects in the same event. For example:

    Bullet On collision with SpaceShip

    -----------------> SpaceShip Subtract 1 from health

    -----------------> HealthBar set width to SpaceShip.health

    (notice you don't need to pick this spaceship's HealthBar , it's picked automatically)

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