mirror of
https://github.com/photonstorm/phaser
synced 2025-01-07 02:38:53 +00:00
Moved queued sound actions logic from update method to unlocked event handler
This commit is contained in:
parent
fb52e3d490
commit
bcb11d5c4e
1 changed files with 24 additions and 29 deletions
|
@ -92,6 +92,30 @@ var HTML5AudioSoundManager = new Class({
|
||||||
tag.load();
|
tag.load();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
this.once('unlocked', function () {
|
||||||
|
var allSoundsTouchLockedActionQueue = [];
|
||||||
|
_this.forEachActiveSound(function (sound) {
|
||||||
|
sound.touchLockedActionQueue.forEach(function (touchLockedAction) {
|
||||||
|
allSoundsTouchLockedActionQueue.push(touchLockedAction);
|
||||||
|
});
|
||||||
|
sound.touchLockedActionQueue.length = 0;
|
||||||
|
sound.touchLockedActionQueue = null;
|
||||||
|
// TODO set correct duration value
|
||||||
|
});
|
||||||
|
allSoundsTouchLockedActionQueue.sort(function (tla1, tla2) {
|
||||||
|
return tla1.time - tla2.time;
|
||||||
|
});
|
||||||
|
allSoundsTouchLockedActionQueue.forEach(function (touchLockedAction) {
|
||||||
|
switch (touchLockedAction.type) {
|
||||||
|
case 'method':
|
||||||
|
touchLockedAction.sound[touchLockedAction.name].apply(touchLockedAction.sound, touchLockedAction.value || []);
|
||||||
|
break;
|
||||||
|
case 'property':
|
||||||
|
touchLockedAction.sound[touchLockedAction.name] = touchLockedAction.value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
document.body.addEventListener('touchend', unlock, false);
|
document.body.addEventListener('touchend', unlock, false);
|
||||||
},
|
},
|
||||||
onBlur: function () {
|
onBlur: function () {
|
||||||
|
@ -108,35 +132,6 @@ var HTML5AudioSoundManager = new Class({
|
||||||
});
|
});
|
||||||
this.onBlurPausedSounds.length = 0;
|
this.onBlurPausedSounds.length = 0;
|
||||||
},
|
},
|
||||||
update: function () {
|
|
||||||
if (this.touchUnlocked) {
|
|
||||||
this.touchUnlocked = false;
|
|
||||||
this.touchLocked = false;
|
|
||||||
var allSoundsTouchLockedActionQueue_1 = [];
|
|
||||||
this.forEachActiveSound(function (sound) {
|
|
||||||
sound.touchLockedActionQueue.forEach(function (touchLockedAction) {
|
|
||||||
allSoundsTouchLockedActionQueue_1.push(touchLockedAction);
|
|
||||||
});
|
|
||||||
sound.touchLockedActionQueue.length = 0;
|
|
||||||
sound.touchLockedActionQueue = null;
|
|
||||||
// TODO set correct duration value
|
|
||||||
});
|
|
||||||
allSoundsTouchLockedActionQueue_1.sort(function (tla1, tla2) {
|
|
||||||
return tla1.time - tla2.time;
|
|
||||||
});
|
|
||||||
allSoundsTouchLockedActionQueue_1.forEach(function (touchLockedAction) {
|
|
||||||
switch (touchLockedAction.type) {
|
|
||||||
case 'method':
|
|
||||||
touchLockedAction.sound[touchLockedAction.name].apply(touchLockedAction.sound, touchLockedAction.value || []);
|
|
||||||
break;
|
|
||||||
case 'property':
|
|
||||||
touchLockedAction.sound[touchLockedAction.name] = touchLockedAction.value;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
BaseSoundManager.prototype.update.call(this);
|
|
||||||
},
|
|
||||||
destroy: function () {
|
destroy: function () {
|
||||||
BaseSoundManager.prototype.destroy.call(this);
|
BaseSoundManager.prototype.destroy.call(this);
|
||||||
this.onBlurPausedSounds.length = 0;
|
this.onBlurPausedSounds.length = 0;
|
||||||
|
|
Loading…
Reference in a new issue