DimaBear Posted May 25, 2017 Share Posted May 25, 2017 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 More sharing options...
DimaBear Posted May 25, 2017 Author Share Posted May 25, 2017 Update Phaser.js Link to comment Share on other sites More sharing options...
squilibob Posted May 27, 2017 Share Posted May 27, 2017 Your code works for me. Link to comment Share on other sites More sharing options...
Recommended Posts