audio ended event

beta.r3js.org
-=yb4f310 2017-11-15 23:54:41 +01:00
parent f2fa1e0be5
commit 57e5f98d26
2 changed files with 11 additions and 2 deletions

View File

@ -67,7 +67,7 @@ GameLib.Event.MATERIAL_TEXTURES_UPDATED = 0x31;
GameLib.Event.DELETE_COMPONENT_ERROR = 0x32;
GameLib.Event.COMPONENT_DELETED = 0x33;
GameLib.Event.COMPONENT_TYPES_UPDATED = 0x34;
//GameLib.Event.SHAPE_INSTANCE_CREATED = 0x35;
GameLib.Event.AUDIO_ENDED = 0x35;
GameLib.Event.COMPONENT_LINKED = 0x36;
//GameLib.Event.SOLVER_INSTANCE_CREATED = 0x37;
GameLib.Event.BEFORE_RENDER = 0x38;
@ -174,7 +174,7 @@ GameLib.Event.GetEventName = function(number) {
case 0x32 : return 'delete_component_error';
case 0x33 : return 'component_deleted';
case 0x34 : return 'component_types_updated';
case 0x35 : return 'unused';//'shape_instance_created';
case 0x35 : return 'audio_ended';
case 0x36 : return 'component_linked';
case 0x37 : return 'unused';//'solver_instance_created';
case 0x38 : return 'before_render';

View File

@ -82,6 +82,15 @@ GameLib.System.Audio.prototype.playAudio = function(data) {
if (audio.name === data.name) {
if (!audio.instance.isPlaying) {
audio.instance.play();
audio.instance.onEnded = function() {
GameLib.Event.Emit(
GameLib.Event.AUDIO_ENDED,
{
audio : audio
}
);
}
}
}
}