JSFiddle - React, Tailwind, and code Playground
JavaScript
/// <reference path="phaser.min.js" />
var game = new Phaser.Game(960, 720, Phaser.AUTO, 'VideoGame', { preload: preload, create: create, update: update });
function preload() {
game.load.image('plane', 'Plane.png');
game.load.image('enemy', 'Enemy.png');
game.load.image('background', 'background.png');
game.load.image('bullet', 'bullet.png');
}
//-----------------------------------------------------------//
var plane;
var bullets;
var Existbullets;
var ExistbulletsTime = 0;
var enemies;
var planePos;
var e;
//-----------------------------------------------------------//
function create() {
//-----------------------------------------------------------//
// This will run in Canvas mode, so let's gain a little speed and display
game.renderer.clearBeforeRender = false;
game.renderer.roundPixels = true;
//-----------------------------------------------------------//
//map
game.add.tileSprite(0, 0, 960, 720, 'background');
game.world.setBounds(0, 0, 1060, 820);
//-----------------------------------------------------------//
//game physic
game.physics.startSystem(Phaser.Physics.P2JS);
game.physics.startSystem(Phaser.Physics.ARCADE);
//-----------------------------------------------------------//
//plane add
plane = game.add.sprite(250, 250, 'plane');
plane.anchor.setTo(0.5, 0.5);
//-----------------------------------------------------------//
//plane physic
// Enable if for physics. This creates a default rectangular body.
game.physics.p2.enable(plane);
// Make things a bit more bouncey
game.physics.p2.restitution = 0.1;
// Modify a few body properties
plane.body.setZeroDamping();
plane.body.fixedRotation = true;
// Enable World Collider
plane.body.collideWorldBounds = true;
//-----------------------------------------------------------//
//plane camera
game.camera.follow(plane);
...