How to detect when a sprite is not clicked?

0 favourites
  • 6 posts
From the Asset Store
Click! Click! 136 click sounds for your video games or media projects
  • A better rephrased question is:

    What's the best way to detect a click that isn't on a sprite?

    Background:

    I have sprites that pop up and the user is supposed to click on them. I'm trying to determine when the user misses clicking on the sprite.

    Possible solutions:

    • Comparing every click with the left/top/right/bottom boundaries of every sprite displayed. But, this seems excessive and I feel that there is a better way. I just haven't found it yet.
    • I added a click detection for the background layer, but unfortunately, that is still triggered when the sprite is clicked.

    Other strategies tried:

    • Adding an inverse or else to an On Object Clicked trigger is not possible.
    • Tried adding a local variable to determine if the currently triggered click was on the sprite, but unfortunately doesn't appear to work well within triggers because they aren't called with the ticks.

    Notes:

    • Testing only in Chrome and with C2 r154.
    • After figuring this out, I will also have to do this for touch events, but that should be simple enough.
  • Hey there!

    Have you tried this?

    <img src="http://jjlistrandomstuff.net16.net/Screens/On_miscklick.JPG" border="0" />

    Should be something similar for touch.

  • Hey there!

    Have you tried this?

    <img src="http://jjlistrandomstuff.net16.net/Screens/On_miscklick.JPG" border="0" />

    Should be something similar for touch.

    I see the pic's URL you are trying to show is called "on_misclick" and that does sound promising. Unfortunately, I can't see the pic. ;]

    Is this from another plugin?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
    • Mouse On Left button Clicked
    • (INVERT) Cursor is over Sprite
    • > Actions
  • Oh, that's weird :O

    Nah, just 1 event with basic C2 logics)

    Yeah, what Cow said :P

  • Thank you both very much! That's exactly what I was looking for!

    Btw, it was a pretty cool effect seeing text created every tick and being faded with the fade behavior. So, in order to make sure this misclick event is only called once, I added a boolean variable. Here's the full working sample that I am using:

    Download "on_misclick" solution (event called once)

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