{"id":19655702,"url":"https://github.com/flogvit/phaser-swipe","last_synced_at":"2025-10-06T05:59:54.039Z","repository":{"id":57322883,"uuid":"46805072","full_name":"flogvit/phaser-swipe","owner":"flogvit","description":"A swipe component for Phaser.io","archived":false,"fork":false,"pushed_at":"2016-04-20T16:55:48.000Z","size":7,"stargazers_count":47,"open_issues_count":0,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-27T10:20:24.208Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flogvit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-11-24T16:46:06.000Z","updated_at":"2024-08-19T10:14:50.000Z","dependencies_parsed_at":"2022-08-31T00:00:48.952Z","dependency_job_id":null,"html_url":"https://github.com/flogvit/phaser-swipe","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flogvit%2Fphaser-swipe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flogvit%2Fphaser-swipe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flogvit%2Fphaser-swipe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flogvit%2Fphaser-swipe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flogvit","download_url":"https://codeload.github.com/flogvit/phaser-swipe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223941872,"owners_count":17229074,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T15:23:08.359Z","updated_at":"2025-10-06T05:59:53.939Z","avatar_url":"https://github.com/flogvit.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# phaser-swipe\nA swipe component for Phaser.io\n\n## Install\n\nYou can grab the swipe.js file and include it in your project, or you can use npm or bower:\n\n```bash\n   npm install phaser-swipe\n   bower install phaser-swipe\n```\n\n## Usage\n\nYou can use it in two ways; with or without a model. This is without model.\n\n```javascript\n  var Swipe = require('phaser-swipe');\n  \n  // in create\n  this.swipe = new Swipe(this.game);\n  \n  // in update\n  var direction = this.swipe.check();\n  if (direction!==null) {\n    // direction= { x: x, y: y, direction: direction }\n    switch(direction.direction) {\n       case this.swipe.DIRECTION_LEFT: // do something\n       case this.swipe.DIRECTION_RIGHT:\n       case this.swipe.DIRECTION_UP:\n       case this.swipe.DIRECTION_DOWN:\n       case this.swipe.DIRECTION_UP_LEFT:\n       case this.swipe.DIRECTION_UP_RIGHT:\n       case this.swipe.DIRECTION_DOWN_LEFT:\n       case this.swipe.DIRECTION_DOWN_RIGHT:\n    }\n  }\n```\n\nThis is with a model. Here you define your methods in your model. Only those methods defined will be used.\nSo if you do not want the diagonals, you can just omit those methods.\n\n```javascript\n   function YourModel() {\n      up: function(point) {},\n      down: function(point) {},\n      left: function(point) {},\n      right: function(point) {},\n      upLeft: function(point) {},\n      upRight: function(point) {},\n      downLeft: function(point) {},\n      downRight: function(point) {}\n   };\n   \n   // in create\n   this.swipe = new Swipe(this.game, yourmodel);\n   \n   // in update. The methods will only be called if you have a swipe.\n   // point: { x: x, y: y }\n   this.swipe.check();\n```\n\n## Keyboard\n\nThe module will automatically understand all arrow keys for understanding up/down/left/right. If you use\nthe model, it will call the methods for you. If you do not use a model, you will get a direction from\ncheck(), but in both ways you will not get a point for where it was pressed.\n\nIt understands the diagonals also, so pressing up and right will return DIRECTION_UP_RIGHT and call\nmodel.upRight() if it exists. Because two keys need to be pressed, the signal for a single key will not\nfire until it is released.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflogvit%2Fphaser-swipe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflogvit%2Fphaser-swipe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflogvit%2Fphaser-swipe/lists"}