Page 1 of 1

Build a Menu [C#]

Posted: Wed May 16, 2007 7:02 pm
by Revan1985
ok, i believe to have posted in wrong section, so i repeat it here

Hi all, i'm trying to build a menu in Irrlicht, for my game, but i've some problem...

1) I'm not able to "Clear" the IGUIEnvironment after i quit from a menu
2) I'm trying to dispose the GUIEnvironment, and recreate it

Code: Select all

                switch(ev.GUIEvent)
                {
                    case(GUIEventType.ButtonClicked):
                        if (id == 101)
                        {
                            menu = 'p';         // Entra nel menu di gioco
                            env.Dispose();
                            env = device.GUIEnvironment;
                            CreateOnlyBackground();
                        }
but it don't work


How can i create it?
Thx :wink:

Posted: Wed May 16, 2007 8:15 pm
by Revan1985
noone can help?

ok, more easy thing...
how can i clear a object?

or better, how i destroy an object [i suppose i need to use Dispose() ] and then recreate it?

why the istructions

env.Dispose();
env = new GUIEnvironment();

don't work?
please, help me, i'm crying :oops:

Posted: Wed May 16, 2007 9:08 pm
by roxaz
try element.Remove();

Posted: Wed May 16, 2007 9:23 pm
by Revan1985
IGUIEnvironment had not a Method called Rmove();

I try a link, but is revealing impossible to convert it in C#

http://irrlicht.sourceforge.net/phpBB2/ ... game+state
and i am becoming crazy...
noone know how do it?

thx :D

EDIT : ehm, there is a core::list like for c#?

Posted: Thu May 17, 2007 10:07 am
by Delight
In IrrlichtNetCP following code should work. Just call the Clear() Function to remove all gui elements

Code: Select all

public static void Clear()
		{
			ClearChildren( env.RootElement );
		}
		
		public static void ClearChildren( GUIElement element )
		{
			GUIElement[] children = element.Children;
			
			for( int i = 0; i < children.Length; i++ )
			{
				if( children[i].Children.Length != 0 )
					ClearChildren( children[i] );

				children[i].Remove();
			}
		}

Posted: Thu May 17, 2007 11:53 am
by Revan1985
:)

you are a god, now this?
thx ^^