在 NPM START 之后,我在这些文件中收到了这些错误。我该怎么办?
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', {
preload: preload, create: create, update: update, render: render });
function preload() {
game.load.tilemap('level12', 'res/level12.json', null,
Phaser.Tilemap.TILED_JSON);
game.load.image('sprite12', 'res/sprite12.png');
game.load.spritesheet('dude', 'res/player.png', 64, 64);
game.load.spritesheet('droid', 'res/droid.png', 32, 32);
game.load.image('starSmall', 'res/star.png');
game.load.spritesheet('coin', 'res/coin.png',32,32 );
game.load.image('background', 'res/sprite3.png');
}
var map;
var tileset;
var layer;
var player;
var facing = 'left';
var jumpTimer = 0;
var cursors;
var jumpButton;
var bg;
var coin;
function create() {
game.physics.startSystem(Phaser.Physics.ARCADE);
game.stage.backgroundColor = '#000000';
bg = game.add.tileSprite(0, 0, 800, 600, 'background');
bg.fixedToCamera = true;
map = game.add.tilemap('level12');
map.addTilesetImage('sprite12');
map.addTilesetImage('coin');
map.setCollisionBetween(1, 12);
map.setCollisionByExclusion([ 13, 14, 15, 16, 46, 47, 48, 49, 50, 51 ]);
layer = map.createLayer('Tile Layer 1');
layer.resizeWorld();
coin = game.add.group();
coin.enableBody = true;
coin.physicsBodyType = Phaser.Physics.ARCADE;
createcoin();
game.physics.arcade.gravity.y = 200;
player = game.add.sprite(150, 900, 'dude');
game.physics.enable(player, Phaser.Physics.ARCADE);
player.body.bounce.y = 0.2;
player.body.collideWorldBounds = true;
player.animations.add('left', [3,2,1,0], 10, true);
player.animations.add('right', [4,5,6,7], 10, true);
game.camera.follow(player);
cursors = game.input.keyboard.createCursorKeys();
jumpButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
game.physics.arcade.overlap(coin, player, killcoin(), null, this);
}
function killcoin(coin,player) {
coin.kill();
}
function createcoin() {
coin = game.add.sprite(50,700, 'coin');
}
function update() {
game.physics.arcade.collide(player, layer);
player.body.velocity.x = 0;
if (cursors.left.isDown) {
player.body.velocity.x = -150;
if (facing != 'left') {
player.animations.play('left');
facing = 'left';
}
}
else if (cursors.right.isDown) {
player.body.velocity.x = 150;
if (facing != 'right') {
player.animations.play('right');
facing = 'right';
}
}
else {
if (facing != 'idle') {
player.animations.stop();
if (facing == 'left') {
player.frame = 0;
}
else {
player.frame = 5;
}
facing = 'idle';
}
}
if (jumpButton.isDown && player.body.onFloor() && game.time.now > jumpTimer) {
player.body.velocity.y = -250;
jumpTimer = game.time.now + 750;
}
}
function render () {
}
所有这些只是 意外的令牌 。 但在另一台PC上它完全有效。有什么不对?有aynone同样的问题?
非常感谢。