Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: overiding a method  (Read 3794 times)

0 Members and 1 Guest are viewing this topic.

fireside

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 211
    • View Profile
overiding a method
« on: August 02, 2007, 01:09:13 AM »

I'd like to override PauseMusic and ResumeMusic so that they fadeout and fadein.  I don't quite understand where to put it from the help file.  Do you just write a method of the same name and put it in the base inc? Or would it better to write a fadeout() fadein()? Still, how do I attach it to the game object.  I don't quite understand that.
« Last Edit: August 02, 2007, 01:12:00 AM by fireside »
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: overiding a method
« Reply #1 on: August 02, 2007, 01:18:05 AM »

typically you attach methods to objects. If you look at the Project Manager, you'd see, that there is a game.script attached.
This file is attached for the Game object so in this file you can override all methods of the game object or create brand new ones.

for example if you put there

method CustomFadeout()
{

}

You can then call Game.CustomFadeout(); from your scripts.
or you can for example override ChangeScene

method Game.ChangeScene(scenename)
{
  // Do some custom stuff here
  Game.ChangeScene(scenename); // call the original method.
}


Hope that helps.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

fireside

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 211
    • View Profile
Re: overiding a method
« Reply #2 on: August 02, 2007, 02:09:13 AM »

Thanks. 
Logged

fireside

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 211
    • View Profile
Re: overiding a method
« Reply #3 on: August 02, 2007, 04:43:29 AM »

One more thing.  How do you call a function so that it will execute and not wait till it's finished.  Like right now, I call the fade out, but everything waits until it's completely faded out.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: overiding a method
« Reply #4 on: August 02, 2007, 10:57:16 AM »

Currently you can't call a method in a separate independent "thread". Only events work that way. So you'd have to do something like this:

Code: WME Script
  1. method SomeMethod()
  2. {
  3.   this.ApplyEvent("SomeEvent");
  4. }
  5.  
  6. on "SomeEvent"
  7. {
  8.   // this code will be called asynchronously
  9. }
  10.  

Of course, events can't have parameters, so one would have to use variables to pass the info tot he event code.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: overiding a method
« Reply #5 on: August 02, 2007, 11:35:30 AM »

or alternatively you can have the "thread" in the script and call

whatever.AttachScript("filename");

Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

fireside

  • Supporter
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 211
    • View Profile
Re: overiding a method
« Reply #6 on: August 02, 2007, 04:57:18 PM »

O.K. thanks. 
Logged
 

Page created in 0.043 seconds with 21 queries.