Posted By: elegant_mistake
Can't figure out how to remove a panel - 12/04/10 01:39
Hi everybody.
I'm adding some things to the "wizard duel" game from the LiteC tutorials.
I added a panel (pTest_pan) with a button that appears before the game. The button must be clicked to start the game.
I can't figure out how to remove the panel and button after the game has started. They stay on the screen.
I tried "ptr_remove" and reset(pTest_pan, SHOW) to no success. Am I missing something really simple?
Thanks for all your help by the way. I am learning 3dgs quickly thanks to all of you.
Posted By: msmith2468
Re: Can't figure out how to remove a panel - 12/04/10 02:31
You must turn the visibility flag off. its going to look something like this
Panel_Name.flags &= ~SHOW;
this should turn the panel and its buttons off.
also look up flags in the manual.
Posted By: elegant_mistake
Re: Can't figure out how to remove a panel - 12/04/10 04:13
Thanks man, but I'm still doing something wrong. I get undeclared identifier errors when I compile it. I guess I'll try again tomorrow.
Here is the relevant section of my code if anybody wants to give some advice, but no big whoop either way.
p.s. What's the best way to post code on the forums?
function main()
{
screen_size.x = 800; screen_size.y = 600; screen_color.blue = 150;
mouse_mode = 4;
PANEL* pTest_pan =
{
bmap = "main.pcx";
pos_x = 250;
pos_y = 200;
button(100, 100, start_button.bmp, start_button.bmp, start_button.bmp, game, null, null);
flags = OVERLAY | SHOW;
}
}
function game()
{
pTest_pan.flags &= ~SHOW;
level_load("shooter.wmb");
while(1)
{
if(winner == 1)
draw_text("Well done! Red wins!", 10, 10, vector(50, 50, 255));
else if(winner == 2)
draw_text("Ouch! Green wins!", 10, 10, vector(50, 255, 50));
wait(1);
}
}
Posted By: Superku
Re: Can't figure out how to remove a panel - 12/04/10 12:31
Why is your PANEL definition inside the main function?! That's why your identifier (pTest_pan) is unknown in your game function. Use [code ] and [/code ] without the spaces to post code.
PANEL* pTest_pan =
{
bmap = "main.pcx";
pos_x = 250;
pos_y = 200;
button(100, 100, start_button.bmp, start_button.bmp, start_button.bmp, game, null, null);
flags = OVERLAY | SHOW;
}
function main()
{
screen_size.x = 800; screen_size.y = 600; screen_color.blue = 150;
mouse_mode = 4;
}
function game()
{
pTest_pan.flags &= ~SHOW;
level_load("shooter.wmb");
while(1)
{
if(winner == 1)
draw_text("Well done! Red wins!", 10, 10, vector(50, 50, 255));
else if(winner == 2)
draw_text("Ouch! Green wins!", 10, 10, vector(50, 255, 50));
wait(1);
}
}
Posted By: elegant_mistake
Re: Can't figure out how to remove a panel - 12/04/10 17:29
Hey thanks. That made it work. Now I am slightly less retarded than I was yesterday. This is a good thing.