How can I compare two instances of a same sprite?

  • How can I compare two instances of a same sprite?

    like if Sprite.X > Sprite.X

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • if Sprite(0).X > Sprite(1).X

    compares instances 0 and 1.

    Note: You CAN'T do this automatically. Autocorrect would only be able to get 'Sprite.X' you really HAVE to go back and retype the "(number)" part.

  • I have 100 of that sprite and i wanna check the distance of all of them with each other, so if the distance of one of the instances is less than 50 with another instance something happens to them.

    How can i do the above scenario?

  • :twisted: I have 100 of that sprite and i wanna check the distance of all of them with each other, so if the distance of one of the instances is less than 50 with another instance something happens to them.

    How can i do the above scenario?

    Loop each instance to detect distance w/ respect to other instances.

    Look at how loops work first.

  • HessamoddinS

    the way I usually do what you want is to put the sprite in a family. Then you can compare an instance to the family

    spritefamily.x > sprite.x would then pick all the instances with an x greater than the one you are interested in

    and then you can do a for each spritefamily to compare them individually to sprite... or whatever else you want.

  • HessamoddinS

    the way I usually do what you want is to put the sprite in a family. Then you can compare an instance to the family

    spritefamily.x > sprite.x would then pick all the instances with an x greater than the one you are interested in

    and then you can do a for each spritefamily to compare them individually to sprite... or whatever else you want.

    Ditto that. Yes use family, easy and simple.

  • You can also use a loop like MPPlantOfficial said, here's a couple of implementations from Colludium and blackhornet that might help:

  • Thanks guys helpful solutions

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