Jump to content

How to implement flick action?


finkophonium
 Share

Recommended Posts

Hi,

 

I'm trying to use a flick action to throw objects across the screen in my game and I was wondering if Phaser supports it. I haven't found anything in the documentation, so I'd like to implement it myself, but I wasn't really sure how. Essentially, I'd just like to know the velocity of the pointer at the time the mouse button is released, and then I can set the velocity of the object in question to that same value.

 

Is there an easy way to access that information? Or, better, a flick/swipe implementation that I just missed?

 

Link to comment
Share on other sites

Phaser.Pointer has 3 properties: position, positionDown and positionUp which you could use to derive the delta / velocity from. Also if you enable history on a Pointer object you'll get a series of coordinates recorded to its _history array, which you could use for smoothing / interpolation of the flick event.

 

game.input.recordPointerHistory = true

    /**    * Sets if the Pointer objects should record a history of x/y coordinates they have passed through.    * The history is cleared each time the Pointer is pressed down.    * The history is updated at the rate specified in Input.pollRate    * @property {boolean} recordPointerHistory    * @default    */    this.recordPointerHistory = false;    /**    * @property {number} recordRate - The rate in milliseconds at which the Pointer objects should update their tracking history.    * @default    */    this.recordRate = 100;    /**    * The total number of entries that can be recorded into the Pointer objects tracking history.    * If the Pointer is tracking one event every 100ms; then a trackLimit of 100 would store the last 10 seconds worth of history.    * @property {number} recordLimit    * @default    */    this.recordLimit = 100;
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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