Meteor和Phaser - 加载资产时出错

时间:2015-07-31 01:34:18

标签: javascript meteor phaser-framework

我使用Meteor运行Phaser从目录中加载.png文件时出现错误。有人可以提供一些如何解决它的指导。

我的环境是

ubuntu 14.04
Meteor 1.1.0.2
Phaser v2.3.0

我的目录结构和文件夹是

cmt@ubuntu:~/projects/myMeteorProjects/issueReplication2$ ls -R
.:
client  index.css  index.html  public  server

./client:
client.js   phaser.js

./public:
car.png

index.html是

<head>
  <title>phaser and meteor</title>
</head>

<body>
  <h1>Phaser and Meteor</h1>

  {{> game1}}
</body>

<template name="game1">
  {{phaserGame}}

client.js是

Template.game1.helpers({
    phaserGame: function() {
    var game = new Phaser.Game(320,320, Phaser.AUTO, 'firstGame', { preload:
 preload, create: create, update:update }); 
    return game;

    function preload() {
        game.load.image('car', './public/car.png');
    }

    function create() {
        car = game.add.sprite(50, 50, 'car');
    }

    function update() {
    }

    function moveBullets (bullet) { 
    }

    function accelerateToObject(obj1, obj2, speed) {
    }
    }
})

最后Chrome中的错误是

Phaser.Loader - image[car]: error loading asset from URL ./public/car.png

1 个答案:

答案 0 :(得分:1)

'./public/car.png'更改为'/car.png'