Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //these constants would have to be defined in your package and game script
- //simple methodwould be to just make a SE_Constants.txt, and #include them to the package and game scripts
- let EV_PLAY_SE = EV_USER+11;
- let SE_SHOT = 1;
- let SE_SHOT2 = 2;
- let SE_CHARGE = 3;
- let SE_EXPLODE = 4;
- //this init would go on the Package script
- let SE_SHOT_OBJ = ID_INVALID;
- let SE_SHOT2_OBJ = ID_INVALID;
- let SE_CHARGE_OBJ = ID_INVALID;
- let SE_EXPLODE_OBJ = ID_INVALID;
- function InitSounds(){
- if(!IsCommonDataAreaExists("SE")){
- CreateCommonDataArea("SE");
- // Set up sound paths and put IDs in common data
- // Obviously if you don't have consistent paths, only call InitSounds() from one place
- SE_SHOT_OBJ = PrepareSE(dir~"shot00.wav");
- SE_SHOT2_OBJ = PrepareSE(dir~"shot01.wav");
- SE_CHARGE_OBJ = PrepareSE(dir~"charge.wav");
- SE_EXPLODE_OBJ = PrepareSE(dir~"explode.wav");
- function PrepareSE(path){
- let se = ObjSound_Create();
- ObjSound_Load(se, path);
- ObjSound_SetLoopEnable(se, false);
- ObjSound_SetSoundDivision(se, SOUND_SE);
- return se;
- }
- }
- }
- ...
- //in the package script
- @Event{
- alternative(GetEventType)
- case(EV_PLAY_SE){
- let sound = GetEventArgument(0);
- alternative(sound)
- case(SE_SHOT){ObjSound_Play(SE_SHOT_OBJ);}
- case(SE_SHOT2){ObjSound_Play(SE_SHOT2_OBJ);}
- case(SE_CHARGE){ObjSound_Play(SE_CHARGE_OBJ);}
- case(SE_EXPLODE){ObjSound_Play(SE_EXPLODE_OBJ);}
- }
- }
- ...
- //in the game script
- //to play SE_SHOT2,
- NotifyEventAll(EV_PLAY_SE, SE_SHOT2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement