How do I distinguish 2 instances of the same objects?

0 favourites
  • 5 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • I have 2 instances of one object - sprite "bouncingBall". I'd like to make a sparkle when they collide in the point that they collide. So i made:

    bouncingBall - on collision with bouncingBall: 
      1. System - create object sparkle on layer 1 at abs(bouncingBall.x-bouncingBall.X),abs(bouncingBall.y-bouncingBall.y)[/code:1v97klbm]
    But it doean't work as C2 takes the same instance to position sparkle - that is of course logical, but how to make it to create object between those 2 instances of bouncingBall?
  • tecbug

    A) You can use the condition

    Object Type -> Pick [...]

    There are several conditions to pick a certain ball.

    I think you should pick the balls by their unique ID

    B) You can give them instance variables that work as an individual ID by which you can pick them. (Object Type -> Instance Variable ("MyID" = 1) --- Action: Place Sparkle on Object.X,Object.Y).

    Checking for an instance variable automatically picks the entities for which these condition is true.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's easier to use a family. Then you test ball - on collision with family, and you address each one.

  • Without families using pick nth instance should work also:

    System -> Pick nth Instance

    If 2 instances collide, picking instance 0 will pick the first instance and instance 1 will pick the 2nd instance

    ON collision bouncingBall with bouncingball

    Pick instance 0 ... do whatever

    Pick instance 1 .. do whatever

    if on pick instance 0 you set two variables to CollisionX = bouncingball.x, CollisionY = bouncingball.y

    then on pick instance 1 you can use your code

    System - create object sparkle on layer 1 at abs(CollisionX-bouncingBall.X),abs(CollisionY-bouncingBall.y)

  • LittleStain - thanks that's best solution.

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