Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: How Unload a Window in Following Scene  (Read 3002 times)

0 Members and 1 Guest are viewing this topic.

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
How Unload a Window in Following Scene
« on: November 21, 2008, 02:28:18 AM »

I have a window called Box in one scene.  I can't seem to get rid of it in the next scene.

I tried:

Code: WME Script
  1.  
  2.  
  3.  

I also tried:

Code: WME Script
  1. Game.UnLoadWindow("scenes\Greet\Box.window");
  2. Box.Visible = false;
  3.  

Neither work.  :o  Greet is the name of the scene the Box.window object is in.

I see there's a function Close--but don't know how to word the entire command.

If you had a window you wanted to appear globally in most scenes but not all, would you add it in system like the inventory and not in a scene?  Or would the first scene you loaded it in keep it in all the other scenes unless you suppressed it somehow? 


 
« Last Edit: February 19, 2009, 08:29:33 PM by Catacomber »
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: How Unload a Window in Following Scene
« Reply #1 on: November 21, 2008, 04:44:22 AM »

OK, I solved it.

In the following scene, I loaded the window but set it to visible=false.

Code: WME Script
  1. Game.LoadWindow("scenes\Greet\Box.window");
  2. Box.Visible = false;
  3.  


That's nice to know because now I have a hint how I could keep a window up but modify its contents--maybe--will experiment with this. : )

I still don't understand why I couldn't get rid of it--that is unload it completely since I'll never use it again.  Is there a way to do that?  There has to be cause I can't imagine that you'd have to change every scene after you load a window to show the window as visible false.   ::slug

My other question is still something I'm curious about:

If you had a window you wanted to appear globally in 99% of the scenes but not all, is it somehow more efficient to add it in system? Would that in any way keep the file size down?  My guess is yes.



« Last Edit: February 19, 2009, 08:29:52 PM by Catacomber »
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  

Azrael

  • Regular poster
  • ***
  • Karma: 9
  • Offline Offline
  • Gender: Male
  • Posts: 155
    • View Profile
    • Mad Orange
Re: How Unload a Window in Following Scene
« Reply #2 on: November 21, 2008, 07:30:58 AM »

If you don't need this window anymore, or only sometimes, you can use:

Code: [Select]
Game.UnloadObject(Object)
Removes an object from memory.

Parameters
Object
The object to be removed from memory.
Remarks
If you load an object using the Game.LoadActor, Game.LoadEntity and similar methods, you should unload those when you no longer need them to free memory. Otherwise those objects will be released when the game quits.

For the second question you mean "interface/system" directory? I may be wrong but i don't think that should make some difference. Obviously it's useful for organise the project and find quickly the scripts but i don't think it will be more efficient for game.

Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: How Unload a Window in Following Scene
« Reply #3 on: November 21, 2008, 10:16:24 AM »

When you are loading a window into memory, you should always keep a reference to it, i.e. store it in some variable.

Code: WME Script
  1. var SomeWindow = Game.LoadWindow("path\filenae.window");
  2.  

To destroy the window, simply pass this reference to DeleteWindow.

Code: WME Script
  1. Game.DeleteWindow(SomeWindow);
  2.  

You can also use Game.UnloadObject(), both will work.

If your window is visible most of the time, it's probably more effective to only load it once and show/hide it as needed.
Windows that only pop up once in a while should be destroyed afterwards.

You should ALWAYS destroy windows that are no longer needed. They are never destroyed automatically by the engine (only when the game quits). So if you keep loading windows and never destroy them, you'll clutter the memory and it will result in long save/load times.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Catacomber

  • Supporter
  • Frequent poster
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 443
  • I love mice.
    • View Profile
    • Catacomber.com
Re: How Unload a Window in Following Scene
« Reply #4 on: November 21, 2008, 04:07:29 PM »

Thank you both for your help.   :D
Logged
http://www.catacomber.com/
Code: WME Script
  1. Mnemonic is wonderful.
  2.  
 

Page created in 0.065 seconds with 21 queries.