How to use object indexing

0 favourites
  • 3 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • Hi there,

    I have an object 'MyObject' with an instance variable 'SomeValue'.

    Within a loop I'm trying to get the value of the instance variable as follows:

    MyObject(3).SomeValue

    This doesn't work, because the C3 intellisense doesn't give me the option to choose a property after the dot.

    What I am missing?

    Thanks,

    Ueli

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not sure exactly what's wrong here, because any Sprite.Value should always return the number of that value. Is your program not returning a value, do you not know how to access it, or is it something else?

  • C2 just did not autocomplete at all.

    C3 auto completes with only system expressions. Guess that looks like a bug.

    Work around it by first typing MyObject.SomeValue.

    The type the (3) in between them to get MyObject(3).SomeValue (with auto complete)

    But be aware of this. That value between the ( ) is the IID (it is in c2) for all items, whatever is picked.

    Unless the loop runs trough ALL instances in the SAME order as they are created, it has no function.

    -------------------------- <---- no pre-picking

    For each MyObject <- runs trough them in creation order

    Compare two values ... first = MyObject(loopindex).SomeValue =? second ... 5

    Compare two values ... first = MyObject(loopindex + 1).SomeValue =? second ... 5

    Compare two values ... first = MyObject(loopindex + 2).SomeValue =? second ... 5

    __________ Actions

    To test if 3 consecutive SomeValue's are = 5 ...

    Works flawless.

    This will not work

    Is on Screen (MyObject) <-- prepick

    System: For each MyObject order by MyObject.?X ascending <-- & wrong order

    Compare two values ... first = MyObject(loopindex).SomeValue =? second ... 5

    Compare two values ... first = MyObject(loopindex + 1).SomeValue =? second ... 5

    Compare two values ... first = MyObject(loopindex + 2).SomeValue =? second ... 5

    __________ Actions

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