calling sounds from script,. .

If there is something important you think is missing in the current version of ZGameEditor then you can post a feature request here!

Moderator: Moderators

Post Reply
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

calling sounds from script,. .

Post by jph_wacheski »

Would be very useful to have something like; playSound(Sound, NoteNr, Channel);

Lots of times it would be way better,.. ;)
iterationGAMES.com
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:)

Would be handy indeed .. but as long as variable types such as Sound / Mesh / Material aren't supported, functions like these won't be possible ( as far as I know ).

However, you can set this up yourself.

Image

So you have a Repeat loop ( after all your logic ) that goes through a Array containing all the sounds that need to be played this frame. Each loop the PlaySound component is updated using something like this.

Code: Select all

int S = SoundRepeat.Iteration;

switch(Sound[S,0])
{
  case 0: Play.Sound = Bass; break;
  case 1: Play.Sound = Kick; break;
}

Play.NoteNr = Sound[S,1];
Play.Channel = Sound[S,2];
Then your function can then look something like this.

Code: Select all

void playSound(int Sound, float Note, int Channel)
{
  int S = SoundSize;

  Sound[S,0] = Sound;
  Sound[S,1] = Note;
  Sound[S,2] = Channel;

  SoundSize++;
}
K
Post Reply