Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

follow mouse not working with platformer?


Gods
 Share

Recommended Posts

http://codepen.io/anon/pen/qEKONO?editors=001

I am trying to add controls so if the mouse is anywhere on the left side of the character the character goes to the left and vise vera 

I am following this example http://examples.phaser.io/_site/view_full.html?d=input&f=follow+mouse.js&t=follow%20mouse


The reason I want this is so it works on mobile. I copied the example and my game crashes :/ 
http://codepen.io/anon/pen/qEKONO?editors=001

Is this because follow mouse can't only make a character move vertical? 

Link to comment
Share on other sites

if (game.input.activePointer.isDown && player.sprite.x > game.input.activePointer.x) {     player.sprite.body.velocity.x = -100;} else if (game.input.activePointer.isDown && player.sprite.x < game.input.activePointer.x) {     player.sprite.body.velocity.x = 100;}

I'm a very novice programmer, but maybe something like this?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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