HTML5游戏无效 - phaser.js

时间:2018-01-21 11:35:07

标签: javascript html ios debugging

基本纲要:

我正在通过JS借助[howlerjs.com]为音频和[phaser.io]进行图形和物理开发游戏。该游戏托管在[ygdqe.co.nf]。我目前拥有的代码是[main.js],[index.html],[phaser.js]和[howler.js],它们都可以在域的根目录中找到。我的主要问题是加载[index.html] - 它有链接到所有提到的js - 它只显示一个空白页面。

请注意,我目前没有笔记本电脑,所以我在IOS上加载了Chrome中的所有代码。

链接:

[phaser.js]:HTTP://ygdqe.co.nf/phaser.js

[main.js]:HTTP://ygdqe.co.nf/main.js

[howlerjs.com]:HTTPS://github.com/goldfire/howler.js

[phaser.io]:HTTPS://phaser.io

[ygdqe.co.nf]:HTTP://ygdqe.co.nf

[howler.js]:HTTP://ygdqe.co.nf/howler.js

[index.html的]:HTTP://ygdqe.co.nf/index.html

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'KABOOMSSS', { preload: preload, create: create, update: update });
function preload() {
game.stage.backgroundColor = '#85b5e1';
game.load.crossOrigin = 'anonymous';

game.load.image('player', 'phaser-dude.png');
game.load.image('platform', 'platform.png');

}
var player;
var platforms;
var cursors;
var jumpButton;
var xtime;

function create() {
var xtime = 0;

player = game.add.sprite(100, 200, 'player');

game.physics.arcade.enable(player);

player.body.collideWorldBounds = true;
player.body.gravity.y = 500;

platforms = game.add.physicsGroup();

platforms.create(500, 150, 'platform');
platforms.create(-200, 300, 'platform');
platforms.create(400, 450, 'platform');

platforms.setAll('body.immovable', true);

cursors = game.input.keyboard.createCursorKeys();
jumpButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
game.input.onTap.add(onTap, this);
var sound = new Howl({
src: ['http://soundimage.org/wp-content/uploads/2016/11/Automation.mp3']
});
function onTap () {

if (xtime == 0) {
} else if (xtime != 0) {
sound.play;
}
var xtime = (xtime + 1);
}

function update () {

game.physics.arcade.collide(player, platforms);

player.body.velocity.x = 0;

if (cursors.left.isDown)
{
    player.body.velocity.x = -250;
}
else if (cursors.right.isDown)
{
    player.body.velocity.x = 250;
}

if (jumpButton.isDown)
{
   player.body.velocity.y = -400;
}
}
function render () {

}

0 个答案:

没有答案