Added sound trigger (one time and cyclic)

This commit is contained in:
Sachith Hasaranga Seneviratne 2014-07-12 09:13:47 +05:30
parent 44d502d1fe
commit acd11ce738
2 changed files with 19 additions and 6 deletions

View File

@ -27,12 +27,15 @@ void haybail_deactivate()
<object type="action-trigger" action="haybail-activate" distance="10.0" xyz="69.97 8.08 -107.84" hpr="0.0 -0.0 0.0" scale="7.00 7.00 7.00"/>
*/
displayMessage("Haybail reactivated");
//enableAnimation("hayBail.b3d");
squashKart(0,35.0); //id of kart,time to squash
TrackObject @t_obj = getTrackObject("hayBail.b3d");
Animator @haybailAnimator = t_obj.getAnimator();
haybailAnimator.setPaused(false);
displayMessage("Haybail reactivated");
//enableAnimation("hayBail.b3d");
squashKart(0,35.0); //id of kart,time to squash
TrackObject @t_obj = getTrackObject("hayBail.b3d");
Animator @haybailAnimator = t_obj.getAnimator();
haybailAnimator.setPaused(false);
TrackObject @moo_sound = getTrackObject("cow");
SoundEmitter @cowmoo = moo_sound.getSoundEmitter();
cowmoo.playOnce();
}

View File

@ -83,6 +83,14 @@ namespace Scripting
{
((TrackObjectPresentationSound*)memory)->stopSound();
}
void playOnce(void *memory)
{
((TrackObjectPresentationSound*)memory)->triggerSound(false); //false = once
}
void playLoop(void *memory)
{
((TrackObjectPresentationSound*)memory)->triggerSound(true); //true = loop
}
void setLoop(int start, int end, void *memory)
{
((TrackObjectPresentationMesh*)(memory))->setLoop(start,end);
@ -182,6 +190,8 @@ namespace Scripting
r = engine->RegisterObjectMethod("TrackObject", "SoundEmitter @getSoundEmitter()", asMETHOD(TrackObject, getSound), asCALL_THISCALL); assert(r >= 0);
r = engine->RegisterObjectMethod("SoundEmitter", "void move(Vec3 &in)", asFUNCTION(movePresentation), asCALL_CDECL_OBJLAST); assert(r >= 0);
r = engine->RegisterObjectMethod("SoundEmitter", "void stop()", asFUNCTION(stop), asCALL_CDECL_OBJLAST); assert(r >= 0);
r = engine->RegisterObjectMethod("SoundEmitter", "void playOnce()", asFUNCTION(playOnce), asCALL_CDECL_OBJLAST); assert(r >= 0);
r = engine->RegisterObjectMethod("SoundEmitter", "void playLoop()", asFUNCTION(playLoop), asCALL_CDECL_OBJLAST); assert(r >= 0);