npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

phaser-swipe

v1.0.4

Published

A swipe component for Phaser.io

Downloads

107

Readme

phaser-swipe

A swipe component for Phaser.io

Install

You can grab the swipe.js file and include it in your project, or you can use npm or bower:

   npm install phaser-swipe
   bower install phaser-swipe

Usage

You can use it in two ways. With or without a model. This is without model

  var Swipe = require('phaser-swipe');
  
  // in create
  this.swipe = new Swipe(this.game);
  
  // in update
  var direciton = this.swipe.check();
  if (direction!==null) {
    // direction= { x: x, y: y, direction: direction }
    switch(direction.direction) {
       case this.swipe.DIRECTION_LEFT: // do something
       case this.swipe.DIRECTION_RIGHT:
       case this.swipe.DIRECTION_UP:
       case this.swipe.DIRECTION_DOWN:
       case this.swipe.DIRECTION_UP_LEFT:
       case this.swipe.DIRECTION_UP_RIGHT:
       case this.swipe.DIRECTION_DOWN_LEFT:
       case this.swipe.DIRECTION_DOWN_RIGHT:
    }
  }

This is with a model. Here you define your methods in your model. Only those methods defined will be used So if you do not want the diagonals, you can just omit those methods.

   function YourModel() {
      up: function(point) {},
      down: function(point) {},
      left: function(point) {},
      right: function(point) {},
      upLeft: function(point) {},
      upRight: function(point) {},
      downLeft: function(point) {},
      downRight: function(point) {}
   };
   
   // in create
   this.swipe = new Swipe(this.game, yourmodel);
   
   // in update. The methods will only be called if you have a swipe.
   // point: { x: x, y: y }
   this.swipe.check();

Keyboard

The module will automatically understand all arrow keys for understanding up/down/left/right. If you use the model, it will call the methods for you. If you do not use a model, you will get a direction from check(), but in both ways you will not get a point for where it was pressed.

It understands the diagonals also, so pressing up and right will return DIRECTION_UP_RIGHT and call model.upRight() if it exists. Because two keys need to be pressed, the signal for a single key will not fire until it is released