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
.
Touch gesture - Drag makes paint(Graphics g) behaviour odd
-
11-07-2023 - |
Вопрос
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?
Решение
Другие советы
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");
}
Не связан с StackOverflow