Dylan Meeus
Dylan Meeus

Reputation: 5802

Touch gesture - Drag makes paint(Graphics g) behaviour odd

I am overwritting the default paint method, and everything is working fine. I have a running game in CodenameOne (plays smooth, everything works), but the downside is: I had to use buttons for player movement. I would like to use "swipe" gestures, which is in itself a relatively simple implementation. However, when I swipe on the screen, what is painted gets removed, so I am left with just the background (for a split second, the paint continues when releasing the drag).

Any idea on how to fix this issue - without overriding the behaviour of touch gestures?

Upvotes: 0

Views: 127

Answers (2)

Shai Almog
Shai Almog

Reputation: 52770

You shouldn't override paint in Form, it has some special cases. The best workaround is to create a component and place it in a BorderLayout.CENTER in the Form.

Upvotes: 1

Dylan Meeus
Dylan Meeus

Reputation: 5802

A solution I have at the moment is the following. Everything still seems to work!

public void pointerDragged(int x, int y)
{
    System.out.println("This shouldn't do anything");
}

public void pointerDragged(int[] x, int[] y) 
{
    System.out.println("This shouldn't do anything either");
}

Upvotes: 0

Related Questions