Jump to content

Tutorials Or Code Examples About Touch Events


bolatro
 Share

Recommended Posts

Does Anyone known about good touch-related phaser tutorials or game with that kind of source code? Phaser examples is having only two post about touch events - one about debugging and another about joystick. And they both does not describe touch events work well I think. Because in debug example all magic occurs under the hood and joystick example used secondary library.

Please, link there, if you know good staff about this. I think i will be helpful for all. Thanks.

Link to comment
Share on other sites

Just imagine they are the same as a keyboard event. You look at the touch event and then use them the same as you would a key event. The difference only really being the dragging of the finger. I had a few issues but once you grasp the idea its fairely simple. Ie:

if(pointer1.isDown && pointer1.y < 0) { swipeUp(); }

swipeUp: function()

{ Console.log('swiped up!'); }

Thata relatively simple way of using touch.

The pointers are set as pointer1, pointer2 etc etc as well as adding pointers like the multi touch example shows.

Hopefully that has some use to you and you get the idea soon :)

Link to comment
Share on other sites

In the multi touch examples it tells you that pointer1 is 1 finger and pointer2 is 2nd finger.

So if you think of the finger as a mouse pointer and code accordingly to it.

Its quite simple depending on what use you need for touch events. Using pointer1 for example means that ONLY the finger can be used at the time for that code given. You can also have activePointer which accounts for mouse or finger. Which ever is being used really. You would code for pointer1 if you were coding specific to mobile and seperate from mouse pointer and desktop (if that makes sense)

Use activePointer.isDown as a starting point and then if you need to start coding for pointer1 specifically if needed. Hope that makes a bit more sense.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...