Swipe and Select Links using FantomCX

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
Did it work? Another thing that at least I keep forgetting is that the Hit commands are counters and not boolean flags, so I think only false (0) is the right to use when you mix in logic. Because it "returns the number of times the specified finger has made contact with the touchscreen since the last OnUpdate."

Another thing to think about is to never let TouchHit and MouseHit into OnRender, they really need to live in OnUpdate.
 
Last edited:

Pierrou

Active member
Joined
Jul 6, 2017
Messages
230
Code:
       Global _app:cGame   
       (...)

       Class cGame Extends App

        Field fE:cEngine
        Field justClicked:Bool 'have we just touched an object?
        Field justClickedOnASpecificButton
       (...)

        Method OnUpdate()
 
            (...)
            If TouchDown(0)
                fE.TouchCheck()
            EndIf
     
            If justClicked = True And TouchDown(0) = False
                justClicked = False
                _app.accelSwipe = 0 'stop swipe
                If _app.justClickedOnASpecificButton = True 'see which object has been touched
                            (activate link...)
                            (...)
                EndIf
            EndIf
            (...)
         End Method
       (...)
       End Class


        Class cEngine Extends ftEngine
            '------------------------------------------
            Method OnSwipeDone:Int(touchIndex:Int, sAngle:Float, sDist:Float, sSpeed:Float)
                _app.justClicked = False
                (...)
            End Method
            (...)
      
            Method OnObjectTouch:Int(obj:ftObject, touchId:Int)      

                        Select obj
                            Case _app.someSpecificButton

                                _app.justClicked = True
                                _app.justClickedOnASpecificButton = True
                                (...)
                        End
          
                    (...)
            End Method
            (...)
        End Class
(...)


Function Main:Int()
   
    _app = New cGame
   
    Return 0
End

Something like that seems to work, there's probably a better way to do so.

My first inspiration came from the SwipeDetection.cxs in the examples section of the FantomCX manual.
 
Last edited:

Pierrou

Active member
Joined
Jul 6, 2017
Messages
230
I spent 1,5 hour discovering that setting SetSwipeDeadDist to zero is a stupid thing to do since on some phones any touch activates the OnSwipeDone method even if the user is not swiping (while on most phones everything is OK)

EDIT it turns out I still haven't found something that is working on all Android phones and about to give up, each phone reacts differently that's a true nightmare
 
Last edited:

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,135
EDIT it turns out I still haven't found something that is working on all Android phones and about to give up, each phone reacts differently that's a true nightmare
That is why I dislike mobile.

But if you think the swipe class is the problem, just build your own functionality. That class was added by one of the former fantom users.

After all it is just all about determine the conditions when a user does a swipe, the speed/distance, the start and when it ends. Not such a biggy.
But when you use that class, you have to make sure that during a swipe, your game logic only deals with touch input for the swipe and not anywhere else. That is why the class has these the start and end methods.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,135
Adding to this, I must say I find it very brave to use as new tool in such a time constraint project without the time to really test an important functionality and if it really fits your needs.
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
878
I wonder what it could be that makes Android in particular so fragmented in this matter..
 

Pierrou

Active member
Joined
Jul 6, 2017
Messages
230
That is why I dislike mobile.

But if you think the swipe class is the problem, just build your own functionality. That class was added by one of the former fantom users.

After all it is just all about determine the conditions when a user does a swipe, the speed/distance, the start and when it ends. Not such a biggy.
But when you use that class, you have to make sure that during a swipe, your game logic only deals with touch input for the swipe and not anywhere else. That is why the class has these the start and end methods.
I already wrote a few classes fulfilling my needs, like a GUI class, I'm far from a good programmer but it does the job indeed. As you said I don't have much time left to take another path, I'll try to fix what I already have. Thanks!
 
Top Bottom