How do I check which sprite (of a large number of sprites) the user clicked on?

0 favourites
  • 4 posts
From the Asset Store
Jump on numbers in the proper order and reach the sun!
  • Good morning from Germany,

    I am quite new to Construct and would like to ask how the following can be achieved:

    I have a large number of sprites (50 +) on the screen.

    When the user clicks on one of this sprites the name of it should go into global variable to be later compared to another list of sprite names.

    I found out how I can check mouse clicks for each sprite by creating many different events. Unfortunately this way is not very convenient and a little bit difficult to maintain.

    I wonder, if it is possible to create one event which can be called from all of the sprites. E. g. with case-conditions or with looping.

    I am sure there is a more elegant way to achieve this. So help is very appreciated.

    Thanks in advance for your help :-)

    LG F.

  • You can add all sprites into a family "ClickableSprites", and use a single event like this:

    Mouse On object ClickableSprites clicked
    ClickableSprites pick top instance // in case you have overlapping sprites
     .. set var to ClickableSprites.ObjectTypeName
    
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you very much for your reply and help. :-)

    I will try this tomorrow when I am back at my desk.

    LG F.

  • Francesco2020 It appears you don't have a Construct 3 paid license. dop2000 suggestion is the best way to do what you are trying to do but is unfortunately a premium feature. The Free version can't use families. To get what you want without families, the easiest thing to do is, make all your sprites for the menu into different animations in a single sprite. Then you only have 1 object to worry about. Then, name the animation the same thing as the building sprite is named and use the system create object by name method passing in the animation name. It is slightly less simple then using a family but still works just as well.

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