Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1.  
  2. //these constants would have to be defined in your package and game script
  3. //simple methodwould be to just make a SE_Constants.txt, and #include them to the package and game scripts
  4. let EV_PLAY_SE = EV_USER+11;
  5. let SE_SHOT = 1;
  6. let SE_SHOT2 = 2;
  7. let SE_CHARGE = 3;
  8. let SE_EXPLODE = 4;
  9.  
  10. //this init would go on the Package script
  11.  
  12. let SE_SHOT_OBJ = ID_INVALID;
  13. let SE_SHOT2_OBJ = ID_INVALID;
  14. let SE_CHARGE_OBJ = ID_INVALID;
  15. let SE_EXPLODE_OBJ = ID_INVALID;
  16.  
  17. function InitSounds(){
  18. if(!IsCommonDataAreaExists("SE")){
  19. CreateCommonDataArea("SE");
  20.  
  21. // Set up sound paths and put IDs in common data
  22. // Obviously if you don't have consistent paths, only call InitSounds() from one place
  23.  
  24. SE_SHOT_OBJ = PrepareSE(dir~"shot00.wav");
  25. SE_SHOT2_OBJ = PrepareSE(dir~"shot01.wav");
  26. SE_CHARGE_OBJ = PrepareSE(dir~"charge.wav");
  27. SE_EXPLODE_OBJ = PrepareSE(dir~"explode.wav");
  28.  
  29. function PrepareSE(path){
  30. let se = ObjSound_Create();
  31. ObjSound_Load(se, path);
  32. ObjSound_SetLoopEnable(se, false);
  33. ObjSound_SetSoundDivision(se, SOUND_SE);
  34. return se;
  35. }
  36. }
  37. }
  38.  
  39. ...
  40.  
  41. //in the package script
  42. @Event{
  43. alternative(GetEventType)
  44. case(EV_PLAY_SE){
  45. let sound = GetEventArgument(0);
  46. alternative(sound)
  47. case(SE_SHOT){ObjSound_Play(SE_SHOT_OBJ);}
  48. case(SE_SHOT2){ObjSound_Play(SE_SHOT2_OBJ);}
  49. case(SE_CHARGE){ObjSound_Play(SE_CHARGE_OBJ);}
  50. case(SE_EXPLODE){ObjSound_Play(SE_EXPLODE_OBJ);}
  51. }
  52. }
  53.  
  54. ...
  55.  
  56. //in the game script
  57. //to play SE_SHOT2,
  58. NotifyEventAll(EV_PLAY_SE, SE_SHOT2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement