How to add number to variable statement

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

    i have this code and there are 3 sprites in the program

    to access the first sprite for movement i use the below code.

    const object1 = runtime.objects.numbersprite1.getFirstInstance();

    const object2 = runtime.objects.numbersprite2.getFirstInstance();

    const object3 = runtime.objects.numbersprite3.getFirstInstance();

    object1.x=50;

    so if i want to select another object with variable eg number=2,

    how can i select object

    e.g i am trying

    object(number).x =50;

    object('number').x =50;

    object("number").x =50;

    "object(number).x =50;"

    what would be the correct statement to use, above 4 wont work

    thankyou

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's not totally clear what you're trying to do, but the idea of picking objects with conditions simply does not apply in JavaScript, that's a concept that is unique to event sheets. If you want to find an instance with a particular variable value, you'll need to write your own code to find it, such as by looping through all instances and checking each instance's variable values. (That's what conditions do internally.)

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