Tap object not working as intended.

0 favourites
  • 7 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hi, i have a strange issue. I have a sprite, when you tap on it a new sprite with a magnifying glass should appear on it, clicking on it a text box is created with description and magnifyng glass sprite is destroied. problem is that when you tap, the magnifying glass sprite won't appear because the same tap is triggered for both action, so only text will appear on top...

    I tried to solve adding a 0,01 wait, but then when i click on m. glass, the TAP will be triggered both for that sprite and the one underneath, creating again the m. Glass sprite on it... do not know if i've explained it well (sorry for my bad english...)

  • If I understood your problem right, then change the event's like this:

    Tap on object - create magnifying glass

    Tap on magnifying glass - destroy it

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • pcprice76

    I was dealing with a similar mouse issue last night - I was doing something when the left mouse button was clicked on an object. But I was also doing something while the left button was down in another fuction. Out of curiosity, I put a counter in that button down function, and it was getting called on average 9 times along with the first routine. And that was just a normal short mouse click.

    Things generally happen a lot quicker than you think. I bet C2 thinks your "touch" event happens for quite a few ticks. On the first tick of the touch it creates the m.Glass, then the next tick thinks you are touching the m.Glass. so starts running that code. The 0.01 second delay may not be long enough.

    Another issue I ran into months ago is that a tap on objects that overlap registers as a tap on all of them. So, you need to make a way to disable the first sprite while the m.Glass sprite is visible. Then re-enable it when you destroy the m.Glass one. Making the first sprite invisible will not work - the tap will still be processed for it. you have to disable the events where it processes the tap, or move the sprite off screen, or add conditions that say not to process the tap if the m.Glass sprite is overlapping or visible.

  • If you have both mouse and tap commands in your game they read as the same command for tap on object and click on object.

    On Tap On Object............ Create MagnifyingGlass on Position Object

    ----------------------------------- Destroy Object

    On Tap On Magnifying Glass- Open Textbox

    ----------------------------------------- Create object on Position MagnifyingGlass

    ------------------------------------------ Destroy MagnifyingGlass

    I think that is what you are trying to do?

  • pcprice76

    I was dealing with a similar mouse issue last night - I was doing something when the left mouse button was clicked on an object. But I was also doing something while the left button was down in another fuction. Out of curiosity, I put a counter in that button down function, and it was getting called on average 9 times along with the first routine. And that was just a normal short mouse click.

    Things generally happen a lot quicker than you think. I bet C2 thinks your "touch" event happens for quite a few ticks. On the first tick of the touch it creates the m.Glass, then the next tick thinks you are touching the m.Glass. so starts running that code. The 0.01 second delay may not be long enough.

    Another issue I ran into months ago is that a tap on objects that overlap registers as a tap on all of them. So, you need to make a way to disable the first sprite while the m.Glass sprite is visible. Then re-enable it when you destroy the m.Glass one. Making the first sprite invisible will not work - the tap will still be processed for it. you have to disable the events where it processes the tap, or move the sprite off screen, or add conditions that say not to process the tap if the m.Glass sprite is overlapping or visible.

    YES! You got it... my problem is the sum of your two ones.

    I realized that more then one tap was triggered and i think that with WAIT was solved, because after that the M. Glass was showing up normally. The second issue is that clicking on it,it triggered both overlapping sprites, so, at the same time:

    1) Function description, that describes object and destroy sprite m. Glass

    2) Function object select that triggers the tap on underneath object and creates again the M. Glass on it.

    So the M. Glass remain always on top of the object, never being destroyed (or, better, being destroyed and recreated at the same time)

    In this case WAIT is useless because the problem is that TAP takes both objects and triggers 2 functions.

    I could make the M. Glass appear shifted to the side of touch.X but would prefer to find a way to solve this porblem, 'cause i'm sure that can be useful in future..

  • pcprice76

    There are a bunch of ways to make it do what you want... it depends on how complex your project is. If there is a lot going on, and you want to pause all that and enter a different state, then you would want to put code in different groups and disable groups you don't want running. (that would disable the sprite that creates the m.Glass one, so you don't have to worry about it processing a tap).

    The most simple way is to just make sure the m.Glass sprite is not overlapping the other sprite. I made a quick example of that...

    http://www.rieperts.com/games/forum/Tap.capx

  • pcprice76

    There are a bunch of ways to make it do what you want... it depends on how complex your project is. If there is a lot going on, and you want to pause all that and enter a different state, then you would want to put code in different groups and disable groups you don't want running. (that would disable the sprite that creates the m.Glass one, so you don't have to worry about it processing a tap).

    The most simple way is to just make sure the m.Glass sprite is not overlapping the other sprite. I made a quick example of that...

    http://www.rieperts.com/games/forum/Tap.capx

    Hi, sorry for replying you late, but you gave me really good hints!

    I will for sure use the Group disable feature in some parts of the game, i nvere noticed that before :/

    My first idea was to make M.Glass appear beside the touch.x, but i want to solve the issue the same, because it will appear overlapping some other objects.

    I tried now to put another confition (if M.GLASS is not on layout 0) but... is really, strange, it doesn't work even if is correct...

    M.Glass is not on layout and event is not triggering the same.... really weird...

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