添加一组按钮来播放声音。移相器2

时间:2019-02-09 10:10:23

标签: javascript phaser-framework

我正在Phaser 2上编写我的第一款游戏。增加了一些按钮,这些按钮应该播放从音频标题中播放的声音,这是一个问题。这是要添加的代码:

fx = this.game.add.audio('sound1');
    fx.allowMultiple = true;

    fx.addMarker('app', 1, 1.0);
    fx.addMarker('le', 3, 0.5);
    makeButton('app', 550, 100);
    makeButton('le', 550, 140);

function makeButton(name, x, y) {

    var buttons = this.game.make.button(x, y, 'sound11', click, this, 2, 1, 0);
    buttons.name = name;
   buttons.scale.set(2, 1.5);
   buttons.smoothed = false;
}
function click(buttons) {

    fx.play(buttons.name);

}

它会产生以下错误

  

未捕获的TypeError:无法读取未定义的属性“ make”       在makeButton(Main.js:150)-> var button = this.game.make.button(x,y,'sound11',click,this,2,1,0);       在Game.Main.create(Main.js:142)-> makeButton('app',550,100);

0 个答案:

没有答案