Wintermute Engine > Technical forum

Problem overriding changeScene method

(1/1)

lacosaweb:
Hi, I write my custom Game.ChangeScene method:


--- Code: ---method ChangeScene(Scene_name,fadeout,fadein)
{
global altermenuopciones;
if(Game.ChangingScene)
return;
if(Scene.Name!="negro" && Scene.Description!="intro")
{
if(altermenuopciones==null)
{
altermenuopciones=menu_opciones;
}
else
{
return;
}
}
if(fadeout==null) fadeout=true;
menu_opciones = true;
global selected_item;
Game.SelectedItem = null;
selected_item = null;

if(fadeout==true)
{
Game.FadeOut(250,0,0,0,255);
}

FondoScup(true);
Game.ChangeScene(Scene_name, false, false);
}

--- End code ---


The method works ok but the script stands in memory and never disappear.
In debug console I can see that it gets through to the end, but every time I change scene a new changeScene item is added in memory.
This doesen't happen when I replance the las line of my method "Game.ChangeScene(Scene_name, false, false);" to "Game.ChangeScene(Scene_name);". But I need to change Scene without fade.

HCDaniel:
I'm wondering whether you are accidentally created a recursion, since you are overwriting Game.ChangeScene(arg1,arg2,arg3) - but at the end of your function you are calling it with the same arguments again. According to the docs here http://docs.dead-code.org/wme/scripting_about_methods.html (unfortunately link doesn't work so you need to navigate there yourself) you should explicitly specify that you are calling the "original" method by using the "this" keyword. Might be worth a try ;)

lacosaweb:
Hi, I changed the line
   Game.ChangeScene(Scene_name, false, false);
to
   this.ChangeScene(Scene_name,false,false);

The same result. Any other idea?

Thanks

Navigation

[0] Message Index

Go to full version