When the player taps an object, it adds points to a scoreboard and removes the object. If a player taps a bad object, the player dies.
Everything works on desktop but when I try to view my game on my web server, there is zero tap functionality. I have tried different variations of what is posted in the screenshot below.
pick which ever you looking for like this
Button states is for mobile and pc players too. So you dont need mouse touch and coursor on object.
By the way
I’m sorry but the solution proposed by @Da-Just is completely wrong.
Your initial event disables moving the mouse cursor. So, “the cursor on Taps4” will not work when using touch… the cursor doesn’t move at all.
Get rid of “Move mouse cursor: no” and this should work just fine.
The explanation here is also dead wrong:
@coolguy1 did it correctly the first time. “Touch or button is down” doesn’t pick any objects. It just checks if the button or touch is down. Then after that you can check where the cursor is. No problems there.
The reason I had “Move mouse cursor: no” if I’m recalling this correctly was because if I touched a “tap” the “mouse cursor” would stay in the same spot unless I tapped elsewhere on the screen.
The problem with that is, I have the “taps” objects generating on the screen randomly so if the mouse/cursor position stays the same it would select a tap object by just existing if that makes sense. The outcome of that is it’s randomly adding points or killing the player.
I switched my “taps” objects to have button behaviors and the game is working how it should. I did lose the ability to drag my finger across the screen to quickly remove the “taps” objects but I’m kind of ok with that.
That is true, the mouse cursor hangs out wherever your touch ended. However, the objects shouldn’t get selected because you also have the “touch/mouse button is down” condition. So the object will only get selected if cursor is on AND touch is held.
I’ll walk back a bit and say that this method is OK to do… it’s not inherently wrong, but I wanted to point out why it wasn’t really solving your original problem. I’m actually not entirely sure why this works when you’ve frozen the mouse cursor, my guess is that the button behavior somehow has a more direct input read from the device? In any case, you can totally use buttons if you want, just know that they come with some differences from your original method:
They use more processing power than your method. Buttons use 9-patch sprites which are very costly compared to regular sprites. That might be OK if you have only a few of them, but could slow down your game if you begin to spawn large numbers at a time.
As you noticed, they dont activate by swiping/dragging across them. The “clicked” conditions only fire when the mouse button or touch is released. Although, you can use “cursor on” conditions just like before, but then you’re skipping the button’s functionality anyway.
I went back to the original version and removed the “Move mouse cursor: no” as you suggested. (I swear I had tried a version with/without that)
I’m not sure if I had some weird caching issue before but I think the game is working how it should now. i.e. I can tap or drag without leaving the “cursor” behind and accidentally touching a “tap” object so thank you for your help I appreciate it!