0

好的,我正在尝试从 Phaser 游戏中制作一个包,已经研究了几天,但它似乎不起作用。我想我发现了问题,希望有人可以帮助我解决这个问题!

我设置了一切以使用本地包,这一切都有效。直到我预加载资产。

这是我的菜单类

Menu = function() {
    console.log(this);
}

Menu.prototype = {
    preload: function(){
        this.load.image('background', 'assets/background.png');
        console.log("ok in preload");
    },
    create: function(){
        this.background = this.game.add.sprite(0, 0, 'background');
        console.log("ok in create");
        var text = "We're getting there";
        var style = { font: "23px Arial", fill: "#ff0044", align: "center" };

        var t = game.add.text(game.world.centerX, 0, text, style);
    },
};

我通过这样做来称呼它

game = new Phaser.Game(400, 300, Phaser.AUTO, "gameWindow");
game.state.add('menu', Menu);
game.state.start('menu');

只要我不尝试在预加载功能中加载图像,这一切似乎都可以通过查看控制台日志来工作,如果我这样做只会卡在预加载功能中。

background.png 位于我的根文件夹中“public/assets/background.png”。所以我在想,当我尝试从本地包访问它时,它很难到达那里......

我的 package.js 是这个顺便说一句:

Package.describe({
  summary: "game one"
});

Package.on_use(function (api, where) {
    api.use(['phaserio'], 'client');

    api.add_files(['states/menu.js'],
                  ['client']);

    api.export('Menu', ['client']);
});

有人在那里,看到我做错了什么?提前致谢!

4

1 回答 1

0

you should be able to load public images from the app, but it depends when that preload sequence is running. Packages get parsed first. So is your new game created within a Meteor.startUp ->? by which time the app itself is initialized?

Also you can put assets in the package itself. are you using 0.9? there are some issues with paths for static assets inside packages see this thread:

https://github.com/meteor/meteor/issues/2602

for 0.9 packages you'll have to add a bit more info

Package.describe({
  summary: "phaser for meteor",
  version: '0.0.1',
  git: 'https://github.com/dcsan/package-dev',
  name: "YOURNAME:phaser"
});

currently if you use something like replacing colon with an underscore:

/packages/YOURNAME_phaser/added/path/to/asset.png

if you get phaser wrapped i would also be interested, so please publish it to atmosphere!

于 2014-09-28T18:43:26.827 回答