5 Replies Latest reply on Apr 5, 2007 6:46 PM by DAVID NAJAR

    Using 2 Joysticks

    AndrewNock Level 1
      Hi all,
      I've got the joystick xtra all working fine, I know that it supports 2 joysticks, but question is.. how to use 2 at once. I want the one joystick to detect the up and down movements, and the other for left and right. I've tried the following:

      joystick = xtra("joystick").new()
      joystick.useJoy(1) -- use the first joystick for the demo

      joystick2 = xtra("joystick").new()
      joystick2.useJoy(2) -- use the first joystick for the demo

      But it seems to still use joystick2's movements even when I only ask for joystick (joystick 1). Anyone had any luck using 2? And any tips?
      Cheers!
        • 1. Re: Using 2 Joysticks
          Level 7
          From memory, shouldn't you create just one instance of the Xtra, then use
          joystick.useJoy() to choose which joystick you are currently reading from ?

          Cheers

          Richard Smith


          • 2. Re: Using 2 Joysticks
            AndrewNock Level 1
            HI,
            Realised I was creating another instance of the Xtra...

            but, how do I use the Xtra, then have 2 instances of joystick?
            I've tried using

            joystick1 = xtra("joystick").new()

            joystick1.useJoy(1)
            joystick2.useJoy(2)

            But throws up an error saying 'object expected' on joystick2.useJoy(2)
            • 3. Re: Using 2 Joysticks
              Level 7
              Still from memory, but I think you just...

              movie script....
              -----------------------
              global g_joystick

              on startMovie
              g_joystick = xtra("joystick").new()
              end startMovie
              ------------------------

              on a behavior...
              -------------------------
              global g_joystick

              on exitFrame
              g_joystick.useJoy(1)
              --read your first joystick values here
              g_joystick.useJoy(2)
              --read your second joystick values here

              end exitFrame
              --------------------------

              I think that's right...

              Cheers

              Richard Smith


              • 4. Re: Using 2 Joysticks
                AndrewNock Level 1
                Superb! Thanks for that.

                Tried loads of variations of that, but somehow didn't see that one.. Hey, its monday after all ;0)

                • 5. Re: Using 2 Joysticks
                  DAVID NAJAR Level 1
                  Hi, that’s great you getting on right!!! I just recommends the Enhancer Xtra, is awesome for game development, easy to use, stable, excellent performance and Shockwave Safe.