How do I recognize clicks only on visible part of sprite

0 favourites
  • 9 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hi. In my apps I encountered a problem with Sprites behind other sprites or tiled backgrounds. I use them to hide scrolling elements/text behind the logo and have usually on top and bottom a tiled background on top layer. Now the problem is if a button/sprite is behind it clicks are still recognized. So I added a check for "sprite is overlapping background" before a link is executed. But now if a big image is only a few pixels behind the background no clicks are recognized anymore. Does anyone know a good solution for this? So that the visible part of a sprite is clickable (open link/page etc.) and the invisible part behind another object is not reacting to clicks or touch.

    As a small workaround to show if a link is active I added another sprite on top to show if the link can be clicked but this is not a great solution.

    Example:

    Image Clickable:

    http://www.fotos-hochladen.net/uploads/c2clickabledscxfn2yq5.png

    Image not Clickable (few pixels behind the tiled background on top):

    http://www.fotos-hochladen.net/uploads/c2notclickablejd4ztr3f9x.png

  • Bring whats clickable to dedicated layer ? Filter out whats not on that layer after a click ?

  • But this will not fix the problem with the overlay that prevents scrolling text to be above the UI (the tiled background on top layer)?

    It should be clickable evertime any part of the sprite is visible but the hidden parts behind the tiled background on top should not be clickable.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You should really rethink everything you're doing - a better way to do it would be to have all your buttons in a family, and enable/disable them using variables whenever you see fit.

    That being said, if you want a quick fix you can try to resize your picture's collision box.

  • I think you did not understand my problem. Its not about the static collision box. The collision box is the whole image but when the image is partially hidden behind the UI (global layer) the hidden part should not recognize clicks.

    PS: Text objects dont have a collision check and I added invisible hotspots (sprites) for hyperlinks above them.

  • I understand the your problem (now). Still, it would be nice if you gave a dummy capx with just the problem. I am sure someone will work on it.

  • Single event

    is clicking/touching image

    is not clicking/touching UI (inverted is touching UI)

  • This could be it!

    Sometimes you just miss the easy solutions. I will try if this works. Thanks.

    edit: just remembered that on touch is a single event and does not allow 2 single triggered events at once. But I will take a look at it.

    edit2: It seems to work!

    Thank you very much. I will do more testing later.

  • Your welcome 😊

    Occasionally the old KISS approach is still best 😁

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