So, I am making a card-like game for touch capable platforms. The player’s stuff is shown at the bottom of the screen while the opponent’s stuff is shown at the top of the screen. I’d like to implement a feature where an icon appears where the player is touching, such as a circle centered about their finger, then the player can swipe it toward themself or toward the opponent depending on if it would heal the player or hurt the opponent. I also want to make it so that the swipe will only apply (i.e. the icon will fly in the direction of the swipe to the edge of the screen) only if the player swipes above a certain velocity. I’ve created a HUD to display things like health. It makes sense to me that the icon should also exist in the HUD since it’s a UI element and should appear above everything else.
- Would it be better to implement the icon as an Actor in the game since it will have physics (i.e. velocity)? Although, then it would appear underneath the HUD elements…
- If it is a HUD element, how do I go about getting its velocity when the player’s finger lifts off of the screen?
I’ve tried getting the location of the touch every tick, then getting the location of the release. Then I subtract the release location from the last gathered sample of touch locations and divide the magnitude by the delta time between the two. This should give me an approximation of the velocity at release. However, when debugging I found that the two samples were often the same location even when I swiped across the screen quickly.