• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Controller? Multitouch handling

oddchild

New member
Joined
Jul 18, 2017
Messages
24
Hi All,



I am trying to make a simple game, I was able to make some controls, but only work if they are touched one at a time. How do I make a controller that will allow the user to hit more than one buttons at a time?
 
I'd like to help, but I am not sure what you want to achieve. Could you explain what kind of controller you want to create. Is is some real game controller like for xbox or is it some keyboard controls or maybe some touch input buttons?
It is also easier for us, if you provide some working code that shows the problem and your approach of solving it.
 
Code:
DrawImage btnprayer, 640, 400 'player 1
DrawImage btnprayer, 0, 400

DrawImage imgleft, 690, 400 'player 1
DrawImage imgleft, 60, 400

DrawImage imgright, 775, 400 'player 1
DrawImage imgright, 160, 400


DrawImage imgdown, 730, 400 'player 1
DrawImage imgdown, 110, 400

DrawImage imgup, 730, 350 'player 1
DrawImage imgup, 110, 350


If TouchDown Then

    'restart button

    If datimer < 1 Then
        If TouchX > 400 AND TouchX < 550 And TouchY > 200 AND TouchY < 250 Then
            datimer = 1500
            score = 0
            tractsremaining = 0
            tractsremaining2 =0
        Endif

    EndIf
    'prayer for player2
    If TouchX > 0 AND TouchX < 50 And TouchY > 400 AND TouchY < 450 And firing = False And datimer > 1 Then


        firing = True
        prayerx2 = herox2
        prayery2 = heroy2
        moving = 0
        origin = 2
    EndIf


    'prayer button for player 1

    If TouchX > 640 AND TouchX < 690 And TouchY > 400 AND TouchY < 450 And firing = False And datimer > 1 Then

        firing = True
        prayerx = herox
        prayery = heroy
        moving = 0
        origin = 1
    Endif

    'left for player 2
    If TouchX > 60 AND TouchX < 110 And TouchY > 400 AND TouchY < 450 And datimer > 1 And datimer > 1 Then

        If firing = False Then dadirection2 = 1


        If framer2 < 10 Then framer2 = 10
        'If framer = 12 Then framer = 10
        If framer2 < 13 Then framer2 = framer2 + 1
        If framer2 = 12 Then framer2 = 10



        herox2 = herox2 - 5 -speed2
        If herox = 10 And herox2 = 10 Then
            If mapx > -560 Then mapx = mapx + 5
        Endif
        If herox2 < 10 Then herox2 = 10



    Endif



    'Left Button on Screen for player 1
    If TouchX > 690 AND TouchX < 740 And TouchY > 400 AND TouchY < 450 And datimer > 1 And datimer > 1 Then

        If firing = False Then dadirection = 1
        If framer < 10 Then framer = 10
        'If framer = 12 Then framer = 10
        If framer < 13 Then framer = framer + 1
        If framer = 12 Then framer = 10

        herox = herox - 5 - speed1

        If herox = 10 And herox2 = 10 Then
            If mapx > -560 Then mapx = mapx +5
        Endif
        If herox < 10 Then herox = 10
    End If


    'right button for player 2
    If TouchX > 160 AND TouchX < 210 And TouchY > 400 AND TouchY < 450 And datimer > 1 And datimer > 1 Then
        If firing = False Then dadirection2 = 2
        If framer2 > 0 Then framer2 = 3

        framer2 = framer2 + 1
        If framer2 > 5 Then framer2 = 3
        herox2 = herox2 + 5 +speed2
        If herox2 > 800 Then herox2 = 800
        If herox = 800 And herox2 = 800 Then
            If mapx > -560 Then mapx = mapx -1
        Endif
    Endif


    'button for go right
    If TouchX > 775 AND TouchX < 825 And TouchY > 400 AND TouchY < 450 And datimer > 1 Then
        If firing = False Then dadirection = 2
        framer = framer + 1
        If framer > 5 Then framer = 3
        herox = herox + 5 +speed1

        If herox > 800 Then herox = 800
        If herox = 800 And herox2 = 800
            If mapx < -560 Then mapx = mapx -5
        Endif
    End If

    'button for player 2 to go up


    If TouchX > 110 AND TouchX < 150 And TouchY > 350 AND TouchY < 400 And datimer > 1 Then
        If firing = False Then dadirection2 = 3
        If framer2 > 0 Then framer2 = 3

        framer2 = framer2 + 1
        If framer2 > 2 Then framer2 = 0
        heroy2 = heroy2 - 5 -speed2
        If heroy2 < 0 Then heroy2 = 0
        If heroy = 0 And heroy2 = 0 And mapy < 0 Then mapy = mapy + 5



    Endif
    ' button for go up
    If TouchX > 730 AND TouchX < 780 And TouchY > 350 AND TouchY < 400 And datimer > 1 Then


        If firing = False Then dadirection = 3
        framer = framer + 1
        If framer > 2 Then framer = 0

        heroy = heroy - 5 -speed1
        If heroy < 0 Then heroy = 0
        If heroy = 0 And heroy2 = 0 And mapy < 0 Then mapy = mapy + 5
    Endif


    'down for player 2

    If TouchX > 110 AND TouchX < 150 And TouchY > 400 AND TouchY < 450 And datimer > 1 Then

        If firing = False Then dadirection2 = 4
        If framer2 > 0 Then framer2 = 3

        framer2 = framer2 + 1
        If framer2 > 8 Then framer2 = 6
        If framer2 < 6 Then framer2 = 6
        heroy2= heroy2+ 5 + speed2
        If heroy2> 420 Then heroy2= 420
        If heroy = 420 And heroy2 = 420 And mapy > -720 Then mapy = mapy -1


    Endif

    'button for go down



    If TouchX > 730 AND TouchX < 780 And TouchY > 400 AND TouchY < 450 Then




        If firing = False Then dadirection = 4
        framer = framer + 1
        If framer > 8 Then framer = 6
        If framer < 6 Then framer = 6
        heroy= heroy+ 5 + speed1
        If heroy> 420 Then heroy= 420
        If heroy = 420 And heroy2 = 420 And mapy > -720 Then mapy = mapy -1
    End If



EndIf
 
Last edited by a moderator:
So you are talking about two fingers on the screen, right?
You can use the index of touchX(index) to get the position of multiple fingers.
Just be aware that it is not always the case that the holding finger is index 0 and the hiting one is index 1.
It should be saver to check for both indices if they are on the field or on the button.
 
so instead of TouchX I should use a list? and have it check each item in the list?


Thanks for your help!
 
You just have to check for both TouchX(0) and TouchX(1), no need for a list.
 
Back
Top Bottom