Jump to content

How can I use moveToPointer()


vrnkl
 Share

Recommended Posts

Hi everybody. I need help in my little game.

 

My problem is, how i can move the player using game.physics.arcade.mo?

 

The code in red coler doesn't works. Why?

 

I'm using Intel XDK.

 

 

Thanks.

BasicGame = { };BasicGame.Game = function (game) {        };BasicGame.Game.prototype = {       init: function () {        this.input.maxPointers = 1;        this.stage.disableVisibilityChange = true;        this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;        this.scale.pageAlignHorizontally = true;        this.scale.pageAlignVertically = true;        this.scale.forceOrientation(true, false);        this.scale.setResizeCallback(this.gameResized, this);        this.scale.setScreenSize(true);        this.scale.refresh();        this.game.physics.startSystem(Phaser.Physics.ARCADE);    },    preload: function () {             this.load.image('bg', 'asset/bg-space-easy.png');        this.load.image('player', 'asset/player.png');    },    create: function() {        this.bg = this.game.add.image(this.world.centerX, this.world.centerY, 'bg');        this.bg.anchor.setTo(0.5, 0.5);                      this.player = this.game.add.image(10, 10, 'player');        this.player.anchor.setTo(0.5, 0.5);        this.input.onDown.add(touchCoordinatesDebug, this);        function touchCoordinatesDebug(pointer) {            this.game.debug.inputInfo(32, 32);            this.game.debug.spriteInputInfo(sprite, 32, 130);            this.game.debug.pointer(this.game.input.activePointer);        }    },        update: function() {        this.game.physics.arcade.enable(this.player);        this.player.body.velocity.y += 50;        if(this.game.physics.arcade.distanceToPointer(this.player, this.input.activePointer) > 8) {            this.game.physics.arcade.moveToPointer(this.player, 300);        }        else {            this.player.body.velocity.set(0);        }    },        gameResized: function (width, height) {    }};
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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