在Rails + Phaser上找不到图像

时间:2016-03-31 12:42:06

标签: javascript ruby-on-rails sprite phaser-framework

我正在尝试完成此移相器教程,但我无法加载图像。我首先将以下代码添加到我的一个视图中:

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });

function preload() {

  game.load.image ('sky', 'assets/images/sky.png');
  game.load.image ('ground', 'assets/images/platform.png');
  game.load.image ('star', 'assets/images/star.png');
  game.load.spritesheet ('dude', 'assets/images/dude.png', 32, 48);
}

var platforms;

function create() {

  game.physics.startSystem(Phaser.Physics.ARCADE);
  game.add.sprite(0, 0, 'sky');
  platforms = game.add.group();
  platforms.enableBody = true;
  var ground = platforms.create(0, game.world.height - 64, 'ground');
  ground.scale.setTo(2, 2);
  ground.body.immovable = true;
  var ledge = platforms.create(400, 400, 'ground');
  ledge.body.immovable = true;
  ledge = platforms.create(-150, 250, 'ground');
  ledge.body.immovable = true;
}

出现游戏窗口但没有显示任何图像。当我检查页面时,我可以看到以下错误消息:

Phaser.Loader - image [天空]:从网址资产加载资产资产/ images / sky.png

我尝试加载的每张图片都会出现。我已经检查过路径是否正确,确实如此。任何人都知道发生了什么?

0 个答案:

没有答案