Author Topic: StopClip  (Read 3828 times)

eric22222

  • Fanatic
  • ***
  • Posts: 177
    • View Profile
    • Eric Online
    • Email
StopClip
« on: 2007-12-23, 12:09:53 PM »
With a difficult semester behind us, Adam and I have picked back up on our project, Zinc. I created a pretty spiffy pause screen, and would like to get to it pretty quickly, that is, without waiting for the music to fade out. Since the pause button is scripted, I figured it'd be easier to simply tell the game to quit playing the music rather than go through a complicated string of special functions with assigned media. Here's what I've got:

Code: [Select]
ProjectObj.MediaMgr.Clip(ProjectObj.GamePlayer.rmap.BackgroundMusic).StopClip
Of course, I wouldn't be posting this if all went as planned. I wind up with this error:

Code: [Select]
Argument not optional: 'ProjectObj.MediaMgr.Clip(...).StopClip'
If anyone has any idea on what the problem is and how to fix it, it'd be much appreciated.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2745
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: StopClip
« Reply #1 on: 2007-12-24, 09:18:49 AM »
I don't have the code/help handy here at the moment, but I can offer a suggestion you might not have thought of.  The Help/FAQ forum has a tip about how to switch maps quickly, by forcing the music to stop more quickly.  Could you use that solution?

eric22222

  • Fanatic
  • ***
  • Posts: 177
    • View Profile
    • Eric Online
    • Email
Re: StopClip
« Reply #2 on: 2007-12-24, 01:37:50 PM »
Well, I had considered it, but I bet my main problem with it could be solved. The following gets the desired effect:

Code: [Select]
   ProjectObj.GamePlayer.ActivateFunction ProjectObj.GamePlayer.rmap.Specials("Test")
   ProjectObj.MediaMgr.Clip(ProjectObj.GamePlayer.rmap.BackgroundMusic).StartClip
   ProjectObj.GamePlayer.ActivateFunction(NewFunc)

...where NewFunc is a map swapping function defined in script, and the special function "Test" is only used to change the background music to a short clip. What I don't like with this solution is that it would require me to put a function like Test in every map and set each one to change the background music. Is there any way I can change the background music from script?

I've used a special function's MediaName property for loading games:

Code: [Select]
      Dim MusicFunc
      Set MusicFunc = NewSpecialFunction
      MusicFunc.MediaName = ProjectObj.GamePlayer.rmap.BackgroundMusic
      ProjectObj.GamePlayer.ActivateFunction(MusicFunc)

This solves that annoying problem where loading a game doesn't start the background music. Unfortunately, this only plays the clip with the function; it doesn't change the background music to the clip. My thought is that I can tell it to change background music with something's flag property. Unfortunately, I have no idea which flag I want to set, nor what I should set it to...

</Overdetailed explanation>
Any suggestions for changing the background music in script?

eric22222

  • Fanatic
  • ***
  • Posts: 177
    • View Profile
    • Eric Online
    • Email
Re: StopClip
« Reply #3 on: 2007-12-24, 04:10:28 PM »
Got it! Turns out the problem with my first solution was a very minor usage issue. I just needed to include (false) after my stopclip command.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2745
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: StopClip
« Reply #4 on: 2007-12-25, 07:35:00 AM »
Yes, upon reading your message, I suspected something similar, and was going to suggest looking into that, but it looks like you found it.  I also was going to suggest that if you want to know more about how to perform an action that can also be performed by a special function, you could inspect the ActivateFunction function's source code in the Player.cls source code file (I believe that's where it was).  The VB6 source code should be very similar to the VBScript source code you could use.