Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: lacosaweb on November 06, 2021, 02:19:11 PM

Title: Problem overriding changeScene method
Post by: lacosaweb on November 06, 2021, 02:19:11 PM
Hi, I write my custom Game.ChangeScene method:

Code: [Select]
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);
}


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.

(https://i.imgur.com/F5dHaKu.jpg)
Title: Re: Problem overriding changeScene method
Post by: HCDaniel on November 13, 2021, 11:26:59 AM
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 ;)

Title: Re: Problem overriding changeScene method
Post by: lacosaweb on November 20, 2021, 07:39:59 PM
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