How to trigger when dragging, but not just touching?

0 favourites
  • 5 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I am developing a board strategy game, where turn by turn, each player chooses a troop and aims to a tile. Then an arrow shows up towards that tile.

    My issue is I want to make the aiming by drag. But, if I use condition 'on drag start', as the manual says, it is triggered by a tap or touch, without actually comparing whether the object moves or not. The point is that I have also tried with 'is dragging' and surprisingly, it neither compares movement. So I have no way of making a condition that triggers if one drags the object at least some pixels, but doesn't trigger if one just tap it.

    Has anyone some clue of how to work around that?!AojCIgmN1VlPgYVGFDQ-kKJxZ9TKwQ

    I have an example capx where you can see the starting position of the sprite and the 'triggering' position of it until runtime recognizes it being dragged. Distance before dragging triggers is always 0!!! So 'on drag start' is exactly the same as 'os dragging', for they both get triggered with just a touch or tap. I know one is a trigger by itself and the other is a cpntinuous condition. But, is there a way to triggere something after the dragging has been of at least a few pixels, so a tap wouldn't trigger it as well?

    must add-

    when aiming to a tile, the line of the arrow repositions and changes width and angle according too the troop while dragging, so I need a work around that fits both for one-time triggering and continuously comparing.

    I need to make a 'repeat once' event that triggers at start of drag to activate the troop and reveal the arrow, and another event that keeps repositioning and widening the arrow while dragging.!AojCIgmN1VlPgYVHm4cdRPpOH6ACKA

    Here is a capx more similar to what I intend to do. Actually, the real one has a tilemap with every position value being translated to tiles, lots of functions passing objects as parameters and a simple boolean-toggling turn system to make each player is allowed to aim with only one troop at a given turn. At the end of the round -when each player has aimed or skipped every troop- they move, shoot and fight all at once.

  • Well I fixed the dragging so you can calculate distance :

    To differentiate between tapped or dragged you can say if distancedragged = 0 for tap or distancedragged > 0 for dragging. Because you have the drag and drop behaviour a tap is actually a drag and will trigger 'is dragging' condition.

    Regarding the drag arrow file, I'm confused, can you not build on that file to get what you want? Seems to be close to what you're describing.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh God! Why I didn't come to that by myself? You're right. As simple as per scrolling (touchEnd against touchStart). Checking distance between touches. Comparing arrow position with troop position for triggering might fit as well.

    I have just fixed the sample capx with both options. I'll work with them on my full project to see which takes less code to make stable.

    Refering to touch position implies using at least 4 variables, 2 of them being updated every tick while dragging. Refering to arrow&troop may create some conflict at picking among all troops and arrows around though. Yet simple to work around with sub-events and function parameters.

  • Anyway, my issue was not being able to calculate distance. I had indeed on the event sheet to demonstrate it started recognizing dragging the very moment you touch the object. The problem was that it worked that way. But with your tip, it's simple enough. You saved my day!

  • Great, glad it's fixed :)

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