Mouse click - Superimposed sprites

0 favourites
  • 15 posts
From the Asset Store
Click! Click! 136 click sounds for your video games or media projects
  • i have 2 sprites superimposed on each other.

    the sprite on the "bottom" protrudes half way from the "top" sprite

    is there a way that if i mouse click on the top sprite, I only trigger an event on the top sprite and not on the bottom sprite too?

    thanks

  • Is it two instances of the same sprite?

    Mouse: On Left button Clicked on Sprite

    Sprite: Pick top instance

  • no they are 2 totally different sprites.

    in some occasions I can have 3 sprites on top of each other too.

  • i think i need some way so that when the first mouse click event is triggered, C2 stops checking the other mouse events underneat.

    like and if..else condition structure

  • That's not possible, all clicks run simultaneous.

    What you need is separate events for when objects are overlapping.

    What that order is will determine how you set that up.

    If you don't really care what is clicked when they are over lapping, then you can just make a generic event that covers everything.

  • You could put all the sprites in a family and do what I said above:

    Mouse: On Left button Clicked on Family

    Family: Pick top instance

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I like the idea.

    I have set up a family with 4 sprites to test but cannot find the Pick Top Instance Action :(

  • It's at the bottom of the sprite/family's action list, under "Z order".

  • thanks found the option.

    works, but the action is always processed on the top most sprite of the family, even if i click on the bottom sprite and don't touch the top one :(

  • How about if you add a counter that registers how many objects are clicked, and only do the "Pick top" action if there's more than 1?

  • what i did was to use the ELSE command and start checking ALL sprites from top to bottom. that way the first one that hits is always on top.

    however i would have preferred to use Families as it was a more elegant option.

  • I just tested, if you do it like ramones said it works. It selects only the top sprite of the sprites clicked.

  • yes it works, but it ALWAYS selects the top sprite, no matter on which sprite you click!

    i want to be able to ALSO select the sprite in the middle (of 3 sprites on top of each other), if i click on the middle one!

  • Do you mean if they are on top of each other and completely covering the sprites underneath, or just overlapping? If it's the first case, how would you choose which sprite to pick? If it's the second, it should work.

    Here's my test project if you're interested: PickTopFamily.capx (r99)

  • Nimtrix, yes exactly like in your example.

    works 100% in your case.

    i will have to check again my project & see what i did wrong.

    thanks a lot

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