stop all audio, package.json
parent
2681e8d011
commit
2959d9a62e
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "gamewheel-game-lib",
|
"name": "game-lib",
|
||||||
"description": "Gamewheel Game Library",
|
"description": "Game Library",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cannon": "^0.6.2",
|
"cannon": "^0.6.2",
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
"three": "*",
|
"three": "*",
|
||||||
"through2": "^2.0.1"
|
"through2": "^2.0.1"
|
||||||
},
|
},
|
||||||
"repository": "https://github.com/ToywheelDev/game-lib.git",
|
"repository": "https://bitbucket.org/flyingspoon/editor-game-lib",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
|
|
|
@ -101,7 +101,7 @@ GameLib.Event.GET_SCENE = 0x53;
|
||||||
GameLib.Event.CUSTOM_CODE_WINDOW_RESIZE = 0x54;
|
GameLib.Event.CUSTOM_CODE_WINDOW_RESIZE = 0x54;
|
||||||
GameLib.Event.LOAD_FONT = 0x55;
|
GameLib.Event.LOAD_FONT = 0x55;
|
||||||
GameLib.Event.FONT_NOT_FOUND = 0x56;
|
GameLib.Event.FONT_NOT_FOUND = 0x56;
|
||||||
//GameLib.Event.FONT_INSTANCE_CREATED = 0x57;
|
GameLib.Event.STOP_ALL_AUDIO = 0x57;
|
||||||
GameLib.Event.REGISTER_DEPENDENCIES = 0x58;
|
GameLib.Event.REGISTER_DEPENDENCIES = 0x58;
|
||||||
GameLib.Event.GAME_LOADED = 0x59;
|
GameLib.Event.GAME_LOADED = 0x59;
|
||||||
GameLib.Event.GAME_RESTART = 0x5a;
|
GameLib.Event.GAME_RESTART = 0x5a;
|
||||||
|
@ -208,7 +208,7 @@ GameLib.Event.GetEventName = function(number) {
|
||||||
case 0x54 : return 'custom_code_window_resize';
|
case 0x54 : return 'custom_code_window_resize';
|
||||||
case 0x55 : return 'load_font';
|
case 0x55 : return 'load_font';
|
||||||
case 0x56 : return 'font_not_found';
|
case 0x56 : return 'font_not_found';
|
||||||
case 0x57 : return 'unused';//'font_instance_created';
|
case 0x57 : return 'stop_all_audio';
|
||||||
case 0x58 : return 'register_dependencies';
|
case 0x58 : return 'register_dependencies';
|
||||||
case 0x59 : return 'game_loaded';
|
case 0x59 : return 'game_loaded';
|
||||||
case 0x5a : return 'game_restart';
|
case 0x5a : return 'game_restart';
|
||||||
|
|
|
@ -21,6 +21,8 @@ GameLib.System.Audio = function(
|
||||||
|
|
||||||
this.stopAudioSubscription = null;
|
this.stopAudioSubscription = null;
|
||||||
|
|
||||||
|
this.stopAllAudioSubscription = null;
|
||||||
|
|
||||||
this.audioComponents = [];
|
this.audioComponents = [];
|
||||||
|
|
||||||
this.toPlay = [];
|
this.toPlay = [];
|
||||||
|
@ -61,6 +63,11 @@ GameLib.System.Audio.prototype.start = function() {
|
||||||
this.stopAudio.bind(this)
|
this.stopAudio.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.stopAllAudioSubscription = GameLib.Event.Subscribe(
|
||||||
|
GameLib.Event.STOP_ALL_AUDIO,
|
||||||
|
this.stopAllAudio.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,8 +115,6 @@ GameLib.System.Audio.prototype.playAudio = function(data) {
|
||||||
|
|
||||||
if (!audio.instance.isPlaying) {
|
if (!audio.instance.isPlaying) {
|
||||||
|
|
||||||
console.log('playing audio : ' + audio.name);
|
|
||||||
|
|
||||||
audio.instance.play();
|
audio.instance.play();
|
||||||
|
|
||||||
audio.instance.onEnded = function() {
|
audio.instance.onEnded = function() {
|
||||||
|
@ -132,7 +137,7 @@ GameLib.System.Audio.prototype.playAudio = function(data) {
|
||||||
/**
|
/**
|
||||||
* This audio still has to load
|
* This audio still has to load
|
||||||
*/
|
*/
|
||||||
console.log('delaying play until loaded for: ' + data.name);
|
console.log('delaying audio play until loaded for: ' + data.name);
|
||||||
this.toPlay.push(data.name);
|
this.toPlay.push(data.name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -141,6 +146,16 @@ GameLib.System.Audio.prototype.pauseAudio = function(data) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GameLib.System.Audio.prototype.stopAllAudio = function(data) {
|
||||||
|
this.audioComponents.map(
|
||||||
|
function(audio) {
|
||||||
|
if (audio.instance.isPlaying) {
|
||||||
|
audio.instance.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
GameLib.System.Audio.prototype.stopAudio = function(data) {
|
GameLib.System.Audio.prototype.stopAudio = function(data) {
|
||||||
this.audioComponents.map(
|
this.audioComponents.map(
|
||||||
|
@ -172,5 +187,6 @@ GameLib.System.Audio.prototype.stop = function() {
|
||||||
this.playAudioSubscription.remove();
|
this.playAudioSubscription.remove();
|
||||||
this.pauseAudioSubscription.remove();
|
this.pauseAudioSubscription.remove();
|
||||||
this.stopAudioSubscription.remove();
|
this.stopAudioSubscription.remove();
|
||||||
|
this.stopAllAudioSubscription.remove();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -611,6 +611,13 @@ GameLib.System.Input.prototype.onTouchMove = function (event) {
|
||||||
|
|
||||||
var id = null;
|
var id = null;
|
||||||
|
|
||||||
|
var leftTouch = null;
|
||||||
|
var rightTouch = null;
|
||||||
|
|
||||||
|
if (event.changedTouches.length === 2) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
for (var t = 0; t < event.changedTouches.length; t++) {
|
for (var t = 0; t < event.changedTouches.length; t++) {
|
||||||
|
|
||||||
id = event.changedTouches[t].identifier;
|
id = event.changedTouches[t].identifier;
|
||||||
|
|
Loading…
Reference in New Issue