How do I refer to object names using variables?

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi,

    In my project I have several object named "puzzleGridX" where X can be any of several numbers.

    In the image shown, I'm setting the position of another object to the X and Y values of the puzzleGrid0 object. Is there any way to refer to different puzzleGrid objects with a single expression?

    For example, instead of puzzleGrid0.X, something like: puzzleGrid&AnotherObjectName.number.X

    (where 'AnotherObjectName.number' is an instance variable of another object that contains the number I wish to concatenate to the end of "puzzleGrid"

    Thanks!

  • That's possible with scripting, but not in events.

    You can add these objects to a family, add configure an instance variable ID for them.

    For example, instances of puzzleGrid1 object will have ID=1. Instances of puzzleGrid2 will have ID=2 etc.

    Then you will be able to pick a member of the family and access its properties:

    Family compare ID=AnotherObjectName.number

    DrawingCanvas set position to (Family.x, Family.y)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks!

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