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 }); // canvas  phaser,      . var player; //        . var bg; // ,      function preload() { game.load.image('background', 'img/grid.png'); }  function create() { game.time.advancedTiming = true; game.time.desiredFps = 60; // fps game.time.slowMotion = 2.0; //      ,   0,   2,         bg = game.add.tileSprite(0, 0, 8000, 8000, 'background'); //   game.world.setBounds(0, 0, 8000, 8000);//   game.stage.backgroundColor = "#000"; //   var bmd = generateCircle('red', 20); //      20px player = game.add.sprite(game.world.centerX, game.world.centerY, bmd); //  game.physics.enable(player, Phaser.Physics.ARCADE); //    ARCADE(   phaser.js) game.camera.follow(player); //     }  function update() { game.input.addMoveCallback(function(){ game.physics.arcade.moveToPointer(player, 400); //    ARCADE        }); }  function render() { game.debug.cameraInfo(game.camera, 32, 32); //     }  function generateCircle(color, size){ var bitmapSize = size * 2 var bmd = this.game.add.bitmapData(bitmapSize, bitmapSize); bmd.ctx.fillStyle = color; bmd.ctx.beginPath(); bmd.ctx.arc(size, size, size, 0, Math.PI*2, true); bmd.ctx.closePath(); bmd.ctx.fill(); return bmd; } Source: https://habr.com/ru/post/329652/
All Articles