Bobcp

Swipe not working

Recommended Posts

Hello, i try to create game for mobile devices, and i have a script which work on phaser, but not working on MightyEditor

this.swipeMinDistance = 100;    this.game.input.onDown.add(function(pointer) {        swipeCoordX = pointer.clientX;        swipeCoordY = pointer.clientY;        }, this);    this.game.input.onUp.add(function(pointer) {        swipeCoordX2 = pointer.clientX;        swipeCoordY2 = pointer.clientY;        if(swipeCoordX2 < swipeCoordX - swipeMinDistance){            console.log("left");        }else if(swipeCoordX2 > swipeCoordX + swipeMinDistance){            console.log("right");        }else if(swipeCoordY2 < swipeCoordY - swipeMinDistance){                player.body.velocity.y = -600;        }else if(swipeCoordY2 > swipeCoordY + swipeMinDistance){            console.log("down");        }    }, this);    

How to fix, this?

 

Thank you!

Share this post


Link to post
Share on other sites

Hi,

 

I'm not sure why your code is not working.

I'm guessing one of these will fix your problem:

 

1) check load.js on line 33 it loads first game state - which by default is demo ( change it to play )

2) remove "use strict"; - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

 

here is variant of your code: http://mightyeditor.mightyfingers.com/#p2d6z/0

check play.js

Share this post


Link to post
Share on other sites

Hi,

 

I'm not sure why your code is not working.

I'm guessing one of these will fix your problem:

 

1) check load.js on line 33 it loads first game state - which by default is demo ( change it to play )

2) remove "use strict"; - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

 

here is variant of your code: http://mightyeditor.mightyfingers.com/#p2d6z/0

check play.js

Thank you,

 

but no one of the solution doesn't work

 

I've already change load.js from default, and remove "use strict" dosen't work

 

By the way, in variant of code http://mightyeditor....rs.com/#p2d6z/0, swipe doesn't work, maybe i not right check?

 

I use chrome, and use ctrl+shift+i to open console, then i click on phone icon on left top corner, and try to swipe. In Phaser it's work, but in MightyEditor it's doesn't work

Share this post


Link to post
Share on other sites

hi,

 

you are right - after selecting different device from dev tools it doen't work anymore.

 

I've updated project to phaser 2.4 - now swiping is working - at least from dev tools.

 

same project as above: http://mightyeditor.mightyfingers.com/data/build/p2d6z/0/swipeTest_forum/index.html
 

to find out how to upgrade Phaser - check this topic: http://www.html5gamedevs.com/topic/17173-me-with-new-phaser-version/

Share this post


Link to post
Share on other sites

hi,

 

you are right - after selecting different device from dev tools it doen't work anymore.

 

I've updated project to phaser 2.4 - now swiping is working - at least from dev tools.

 

same project as above: http://mightyeditor.mightyfingers.com/data/build/p2d6z/0/swipeTest_forum/index.html

 

to find out how to upgrade Phaser - check this topic: http://www.html5gamedevs.com/topic/17173-me-with-new-phaser-version/

i've update project to phaser 2.4, and have this error  

 

Uncaught TypeError: Cannot read property 'key' of undefined   (mt.helper.js:12)

	Phaser.Loader.prototype.loadFile = function(){		var file = this._fileList[this._fileIndex];		this.onFileStart.dispatch(this.progress, file.key, file.url);

this code

 

<!-- <script type="text/javascript" src="js/lib/phaser.min.js"></script> --><script type="text/javascript" src="https://rawgit.com/photonstorm/phaser/master/build/phaser.js"></script>

Share this post


Link to post
Share on other sites

You will need to change mt.helper.js also.

Save following file and add to your project. Instead of the default mt.helper.js

 

http://mightyeditor.mightyfingers.com/data/build/p2d3i/0/Phaser24/js/lib/mt.helper2.js

I replace code from mt.helper.js to code from mt.helper2.js, and i have a same error

 

Uncaught TypeError: Cannot read property 'key' of undefined   (mt.helper.js:12)

Share this post


Link to post
Share on other sites

Try to add different file - as mt.helper.js actually is replaced with server version every time.

thank you, it work, but i have this error

 

Uncaught TypeError: Cannot read property 'centerX' of undefined

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.