Dynamic Object Reference?

0 favourites
  • 7 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Is there some way to refer to an object (in this case a sprite) using a name that is generated dynamically?

    For example, with three sprites named "box1", "box2", "box3"

    Is there a way to do something like:

    Global number N? = 2

    System: On start of layout

    System: Create object ("box" & N) on layer 0 at (100, 100)

    In the editor, the Create Object action seems to be designed for an actual object reference, but could a function or array possibly be used here?

  • Isn't there a create by name action?

  • R0J0hound

    Thanks, silly me, of course you're right.

  • OK, after creating the object by name, how would I set a property, say opacity, of that object using the same dynamic reference? It doesn't seem like I can pick the last object created without selecting its type first...

  • You can add all such objects to a family. Then use "Family on created" event.

  • You can add all such objects to a family. Then use "Family on created" event.

    Thanks for this suggestion. Was able to get the layout to work after putting all the various "box" objects into a single family.

    This brings up another question about families or containers (or maybe neither of these)...

    If I want to reposition a bunch of objects as a group, for example, to create a transition where all objects (cards, pieces, dice, etc) on a game board animate off the board in a defined direction, is there some way to define/reference this grouping, using either families or containers (or something else)?

    I'd like to apply animation to the objects as a group, rather than having to pick through the various object types and instances.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If all these objects are the same type (all sprites), then add them to a family, add Bullet behavior to this family.

    For different object types you'll need several families.

    Family is the only way to group many objects and instances and perform some bulk actions with them.

    Containers will not help in this case.

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