Audio test
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.3.0/phaser.js"></script>
JavaScript
var game = new Phaser.Game(640, 480, Phaser.CANVAS, '', null, false, false);
var game_state = {};
var audioJSON = {
spritemap: {
'lvl1_1': {
start: 0,
end: 1,
loop: false
},
'lvl1_2': {
start: 1,
end: 2,
loop: false
},
'lvl1_3': {
start: 2,
end: 3,
loop: false
},
'lvl1_4': {
start: 3,
end: 4,
loop: false
},
'lvl1_4': {
start: 4,
end: 5,
loop: false
},
'lvl1_5': {
start: 5,
end: 6,
loop: false
}
}
};
var button;
var audio;
var audiostate = false;
var playing = false;
var mark = 1;
game_state.main = function () {};
game_state.main.prototype = {
preload: function () {
game.load.spritesheet('button', 'http://examples.phaser.io/assets/buttons/button_texture_atlas.png', 193, 71);
this.game.load.audiosprite('music', 'http://examples.phaser.io/assets/audio/bodenstaendig_2000_in_rock_4bit.ogg', null, audioJSON);
},
create: function () {
text = game.add.text(0, 0, "Audio is Decoding");
game.stage.backgroundColor = '#ffffff';
button = game.add.button(game.world.centerX - 95, 200, 'button', this.mouseclick, this, 0, 1, 2);
button.visible = false;
// ======================================== IN SCOPE
audio = this.game.add.audioSprite('music');
audio.allowMultiple = false;
game.sound.setDecodedCallback([audio], this.donedecoding, this);
audio.onStop.add(this.soundStopped, this);
},
playmarks:...