2022 Developer Survey is open! Take survey.

Hot answers tagged

53 votes
Accepted

How can I quantify a drawn line's straightness?

A perfectly straight line would also be the shortest possible line with a total length of sqrt((x1-x2)² + (y1-y2)²). A more scribbly line will be a less ideal ...
user avatar
  • 111k
32 votes

How can I quantify a drawn line's straightness?

This might not be the best way to implement this either, but I suggest a RMSD (root mean square deviation) could be better, than merely the distance method, in cases mentioned by Dancrumb (see first ...
user avatar
  • 421
24 votes

How can I quantify a drawn line's straightness?

Existing answers do not take into account that the end points are arbitrary (rather than given). Thus, when measuring the straightness of the curve, it does not make sense to use the end points (for ...
user avatar
16 votes
Accepted

How small should touch triggers be at minimum?

There's a comprehensive question on UX about touchscreen button sizes. The recommended size depends highly on your game, but the minimum size is quoted as 9-12mm, about half an inch, and this is based ...
user avatar
  • 14.5k
9 votes
Accepted

LibGDX viewport touch coordinates transformation

I hope I am understanding your question correctly -- if not let me know. I believe the following is where you are unprojecting the coordinates: ...
user avatar
  • 431
4 votes

Actor not taking touch libGDX

I figured out the solution. The problem was that Listeners would work only after we set a bound to our Actor. I hadn't set any ...
user avatar
3 votes

How to detect that user has touched UI canvas in Unity 4.6?

On Mobile you need to need pass Touch.fingerId as parameter into EventSystem.IsPointerOverGameObject(int pointerID), but it is still not perfect, as it fails on TouchPhase.Ended. See this code: <...
user avatar
  • 265
3 votes
Accepted

How do I convert the coordinates of a click to a tilemap position?

I think you're getting your pixel coordinates and tilemap coordinates confused. Tile coordinates count tiles. Pixel coordinates count pixels. To convert from a pixel coordinate to a tile coordinate,...
user avatar
  • 13.3k
3 votes

How can I quantify a drawn line's straightness?

This is a grid based system, right? Find your own points for the line and calculate the slope of the line. Now, using that calculation, determine valid points that the line would pass through, given ...
user avatar
  • 31
3 votes

How can I quantify a drawn line's straightness?

A very easy and intuitive measure is the area between the best fitting straight line and the actual curve. Determining this is fairly straightforward: Use a least-squares fit on all points (this ...
user avatar
  • 884
3 votes
Accepted

Keeping Android device awake

One option is to use a wake lock. Example from the docs: ...
user avatar
3 votes
Accepted

How do I quantify the curvature of a touch swipe?

Detecting swipe curvature Treat the finger swipe as a polyline. Approximate its curvature, and use that as a multiplier for how much to “curl” the resulting shot either left or right. Let's say a ...
user avatar
  • 13.3k
3 votes
Accepted

Testing SFML sf::Touch on ordinary PC

When compiling for a traditional Windows / Mac / Linux desktop setup, no this won't work. I dug through the SFML code and it turns out that the sf::Touch implementation won't really work unless you're ...
user avatar
  • 1,363
3 votes

Distinguish touch gestures for distinct horizontal and vertical commands

The biggest issue is that you're attempting to detect both horizontal and vertical swipes in separate functions but at the same time. When one happens, the other might also happen (unless you swipe ...
user avatar
  • 1,222
2 votes
Accepted

Libgdx - gesture dection

Not sure if this is the best way for detecting gestures, but this is how I would do it: On touchDown() I would set two member variables to store where the touch began. ...
user avatar
  • 1,217
2 votes
Accepted

What is the best practice for handling touch events on different GameObjects in Unity2D?

You have to route the input by priority or z-order. First check HUD or GUI elements (on top) and the actual world ground at last (beneath). If a valid touch target is found/hit then you have to ...
user avatar
  • 403
2 votes

How to flick gameObject using Touch?

t.position == ballPos is causing all your issue. You are comparing 2 vectors which will never be the same. The player will never tap exactly where the ball is. You ...
user avatar
  • 1,401
2 votes

How can I quantify a drawn line's straightness?

The idea is to keep all the points the user touched, then evaluate and sum the distance between each of those points to the line formed when the user releases the screen. Here is something to get you ...
user avatar
  • 15.4k
2 votes

How to know if an actor is touched in libgdx?

Add a Listener to the actor like so. Note you need an InputMultiplexer so your Stage and Screen can both handle touches. Add the Stage first so it gets clicks first, then in the Listener call event....
user avatar
2 votes
Accepted

Libgdx--how to store every single point drawn using touchdragged?

Touch screen record discrete points with a non-constant rate depending on how busy the CPU is and how reliable the hardware readings are. You need to "connect" those points as lines (old point from ...
user avatar
2 votes
Accepted

How do I show a small sprite being dragged by touch?

If you move elements smaller than your finger, there's something wrong with your game design. I see several solutions to this: Make your elements bigger so you can see that you hold and where you ...
user avatar
  • 216
2 votes

In Unity for Android, how do I create touchable buttons?

Since Android devices don't have left/right buttons (well, a long time ago they used to, and if you use bluetooth keyboard/gamepads they will), what you want is onscreen buttons. If you search for ...
user avatar
  • 14.5k
2 votes

atan2 : inversed result? (angle 180 is on the right side, angle 0 on the left side)

You wil want to subtract the touch with the ref point: ...
user avatar
2 votes
Accepted

atan2 : inversed result? (angle 180 is on the right side, angle 0 on the left side)

You're not taking into account the inverted Y axis in comparison to the normal X axis in most (maybe all?) programming languages. The top left corner of the screen is (0, 0), and is positive in the ...
user avatar
2 votes

How can I quantify a drawn line's straightness?

One method you could use is to subdivide the line into segments and do a vector dot product between each vector that represents the segment and a vector representing a straight line between the first ...
user avatar
  • 121
2 votes

LibGDX - how to detect touchUp with GestureListener?

From here, you can see how to use the touchUpmethod that is in the InputProcessor interface with the ...
user avatar
2 votes

How can I clearify users my controlls?

Whenever a game introduces a relatively new or relatively unique control scheme, some users are definitely going to be confused. The easiest way to retain these users is by introducing and allowing ...
user avatar
  • 121
2 votes

How do I tell the difference between tapping and holding the touchscreen?

Why not use touch phase that is built into unity via the Touch class? ...
user avatar
  • 3,516
2 votes
Accepted

How to move my cube left or right using touch Inputs (C#) in unity

Here is an example script to answer your question: ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible