流星和相位器-错误加载资产 [英] Meteor and Phaser - error loading asset

查看:122
本文介绍了流星和相位器-错误加载资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Meteor运行Phaser,从目录加载.png文件时出现错误.有人可以提供一些修复方法的指导.

I run Phaser with Meteor I get an error when loading a .png file from the directory. Could someone please provide some guidance on how to fix it.

我的环境是

ubuntu 14.04
Meteor 1.1.0.2
Phaser v2.3.0

我的目录结构和文件夹是

My directory structure and folders are

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

./client:
client.js   phaser.js

./public:
car.png

index.html是

index.html is

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

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

  {{> game1}}
</body>

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

client.js是

client.js is

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中的错误是

and finally the error in Chrome is

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

推荐答案

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

这篇关于流星和相位器-错误加载资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆