ANDROID: Touchscreen, doppelte bewegung vermeiden?

Previous topic - Next topic

D2O

Hallo,
stück für stück nimmt es formen an.
Aber zu steuerung, hmmm, da steh ich gerade auf dem schlauch  :puke:

Die Touch steuerung funktioniert ansich ganz gut, aber nun bin ich zufällig auf ein nicht gewolltes  feature gestossen  =D
Finger af der linken hälfte des screens, bewegung nach links,
auf der rechten seite nach rechts.
Soweit geht alles normal, ABER,
sind nun beide finger auf einer screenhälfte, verdoppelt sich die bewegung, soweit ist mir das auch klar.
Nur, wie kann ich so etwas vermeiden?

Abfrage von 2 Touch berührungen:

Code (glbasic) Select
SYSTEMPOINTER TRUE

SETSCREEN 1280,720,0
LIMITFPS 60
GLOBAL mx,my,b1,b2
GLOBAL x,i

WHILE TRUE
SETORIENTATION 0 // 1 für Android
FOR i% = 0 TO 1
      SETACTIVEMOUSE i
MOUSESTATE mx,my,b1,b2

IF b1 AND mx < 640
DEC x,4
ENDIF

IF b1 AND mx > 640
INC x,4
ENDIF
NEXT



DRAWRECT x,100,128,128,RGB(0xff, 0x80, 0x40)
SHOWSCREEN
WEND


Solche abfragen wie
Code (glbasic) Select
IF b1 AND i = 0 AND mx < 640
bringen hier natürlich auch nichts.


Kleiner Tipp?

Danke.
I7 2600K; 8 GB RAM ; Win10 Pro x64 | NVidia GTX 750 TI 2048MB ; Realtec OnBoard Sound;
Lenovo ThinkPad T400: XP Pro
GLB Premium-immer Aktuell

kanonet

Da wirst du wohl eine Variable nutzen müssen, gäbe da mehrere Möglichkeiten, ich würde es wahrscheinlich so ähnlich machen:
Code (glbasic) Select
SYSTEMPOINTER TRUE

SETSCREEN 1280,720,0
LIMITFPS 60
LOCAL mx%, my%, b1%, b2%
LOCAL x%, dx%

WHILE TRUE
      SETORIENTATION 0 // 1 für Android

      dx = 0
      FOR i% = 0 TO 1
            SETACTIVEMOUSE i
            MOUSESTATE mx,my, b1,b2
            IF b1
                  IF mx < 640 AND dx>-1
                        DEC dx,4
                  ELSEIF mx > 640 AND dx<1
                        INC dx,4
                  ENDIF
            ENDIF
      NEXT

      INC x, dx
      DRAWRECT x,100, 128,128, RGB(0xff, 0x80, 0x40)
SHOWSCREEN
WEND

Variable dx ist das einzig neue, der Rest sind nur kleine Verbesserungen am Code. Übrigens hat der Ansatz die Bewegung in einer Variable zusammengefasst zu haben auch den Vorteil, dass du Kollisionen und darauf folgende Reaktionen so eventuell besser implementieren kannst.

(Bin gerade auf Arbeit, habe kein GLBasic zum testen, Code kann also kleinere Fehler enthalten.)
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

D2O

Hallo kanonet,
danke :)
Das beispiel funktioniert .

Jetzt habe ich mal einen Ansatzpunkt.
Im Projekt selber hat es noch nicht ganz hingehauen, da hier das ganze scrolling auch mit dran hängt , hmmmpf.
Habe aber dadurch mal was zum testen und lernen.
Ich denke das ich das Moving soweit in eine Function abgekoppelt habe um hier
gefahrlos zu experimentieren.

Vielen Dank mit dem Wink.
I7 2600K; 8 GB RAM ; Win10 Pro x64 | NVidia GTX 750 TI 2048MB ; Realtec OnBoard Sound;
Lenovo ThinkPad T400: XP Pro
GLB Premium-immer Aktuell

erico

heck...another android touch problem?

When you think about your touch controls, you have to think them differently then joystick or keyboard.
Specially because you may want to consider your user to mistakenly touch both ways.

In my case, it is important to keep the last touch as the one user control, but if the last touch is released, the one left pressed must come into account.
So you see it is an alien way to pull out a proper control.

I have been promising a snipet on this for ages...time to push it up.

edit: check this thread:
http://www.glbasic.com/forum/index.php?topic=10214.0

Read the code on the touch part and it may help you out, cheers! :)

D2O

Hallo erico,

so wie ich das sehe und verstehe setzt du die maus manuell Aktive und nicht in einer schleife,
benutzt auch für jede mause eigene variablen.

Auch kein schlechter gedanke.

______________________________________

Hello erico,

as I see it and understand you put the mouse manually Active and not in a loop,
also used for any mause own variable.

Also not a bad thought.
I7 2600K; 8 GB RAM ; Win10 Pro x64 | NVidia GTX 750 TI 2048MB ; Realtec OnBoard Sound;
Lenovo ThinkPad T400: XP Pro
GLB Premium-immer Aktuell

erico

Hope it helps, it is like I said.
In my game I have controls both sides, left right, left jump right jump right over the normal moves.

So it is a 4 buttons touch, 2 each side.
What I need is to resolve the following problem:
Suppose you touch left, then before releasing, you touch right. Here you want the right movement to read, even if left is pressed.
In this scenario, if you then release right with the left still pressed, you want the left movement to read again.

It sounds strange, but in an action fast game, it is important to consider the possibility of multiple touches by user mistake.
In my case, I want the last pressed button to read, and if released, to read another that was pressed and holded before.

It is strange to explain, it is better to implement and test.
I really should have done that snipet in a workable way so people can run the code and feel it instead. :(

Again, I hope it helps your cause.