Jump to content

AngleToPointer does not work


DimaBear
 Share

Recommended Posts

var width = window.innerWidth;
var height = window.innerHeight;

var game = new Phaser.Game(width, height, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
var player;
var bg;
var map_size = 4000;


function preload() {
    game.load.image('unit', 'img/unit.png');
    game.load.image('background', 'img/grid.png');
}
function create() {
    

    game.physics.startSystem(Phaser.Physics.ARCADE);

    game.time.advancedTiming = true;
    game.time.desiredFps = 60;
    game.time.slowMotion = 2.0;
    bg = game.add.tileSprite(0, 0, map_size, map_size, 'background'); 
    game.world.setBounds(0, 0, map_size, map_size);
    game.stage.backgroundColor = "#000";
    

    player = game.add.sprite(game.world.centerX, game.world.centerY, "unit");

    game.physics.enable(player, Phaser.Physics.ARCADE);
    player.anchor.setTo(0.5, 0.5);
    player.body.collideWorldBounds = true;
   
    game.camera.follow(player);   
}

function update() {
    game.input.addMoveCallback(function(){
        game.physics.arcade.moveToPointer(player, 400);
        player.rotation = game.physics.arcade.angleToPointer(player);
    });


}
function render() {
    game.debug.cameraInfo(game.camera, 32, 32);

     game.debug.spriteInfo(player, 32, height-100);
}

Why does not it work AngleToPointer ?

 

P.S. sorry for my English
 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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