Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Need help with sprites

Author
Message
The CodeSmith
20
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 1st Feb 2007 07:08
This code works perfectly (if you have the media), and it lets me click on things and it does what I want.


But if you change PASTE IMAGE commands to this:


The buttons don't work. Can somebody tell me what I am doing wrong and give me an idea of how to fix it?

I'm not who you think...
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 1st Feb 2007 08:00
Im not sure if you realize this, but because the MainMenu() function is recursive, it will eat up stack space, the more you click on the buttons. I think that might also be the problem. Every time you click on a button and successfully return from that function, you re-call MainMenu() which doesn't actually finish the first call to MainMenu(), and I think that this recursiveness along with the sprite command forces DBPro to silently die.

The solution is to replace the MainMenu() call inside the button conditional with EXITFUNCTION.


That will keep it from crashing. Unfortunately now that you have engaged the 3D engine with the sprite command, PRINT will not be as nice to you. But thats another issue.
The CodeSmith
20
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 1st Feb 2007 15:51
I tried your code and changed your "ball.bmp" back to my images and it still doesn't work.


I'm not who you think...
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 1st Feb 2007 16:44 Edited at: 1st Feb 2007 16:55
The problem is by using sprites you have instigated the 3d engine, and thus the 3d backdrop. If you are using the PRINT commands to test your functions are been called properly then you could set backdrop off (can't remember exact command) at the begining of your code. And you will see your functions are called ok.
Now you can code your functions using sprites or put a sync loop in your function so you can see the 2d text. ie

function options()
do
text 0,0,"Hello, welcome to the options menu
sync
loop
endfunction

Also get rid of those EXITFUNCTION commands, your mainmenu() function is not recursive.

*edit*

leaving them in is ok - it won't hurt anything, just they are not needed

leving them in will end the function after whichever option is call, and removing them will end the function a few lines down at endfunction.
Either way the point is mainmenu() does not call itself and is not recursive


The word "Gullible" cannot be found in any English Dictionary.
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 1st Feb 2007 19:13
@The CodeSmith: I stand behind what I said. You used to have a problem when you were calling MainMenu() within MainMenu(), so I suggested you replace that call with EXITFUNCTION. And as Flashing Blade pointed out, EXITFUNCTION is not entirely necessary, because once the call to one of the two Start\OptionsMenu() returns, the MainMenu() function will finish and then return to the loop, where the loop will call it again, thus performing so similarly, as to not merit the need to EXITFUNCTION within the conditional. As for the present; and as both Flashing Blade and I pointed out, there will be new problems with using the PRINT command, once the 3D engine has been engaged. So alternatives to using just PRINT will be necessary to realize that your functions are indeed being called correctly. I suggest taking Flashing Blade's advice on this issue.

@Flashing Blade: You are right, MainMenu() is not recursive anymore. Thats the idea, there were other problems when the function was recursive. Please review the initial post.
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 1st Feb 2007 19:39
@ Pillarofire

Ah yes now I see now the origional code contained calls to the mainmenu() from the mainmenu() if statements.- I only read his 2nd snippet (which was actualy your snippet). Sorry
Although I would say it would be better to just drop the mainmenu() call rather than use the EXITFUNCTION.


The word "Gullible" cannot be found in any English Dictionary.
Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 1st Feb 2007 19:44
its easiest to make 3d panels and paint to them, but i gotta ask indi's permission before i can show you the panels he made for me.

~Kieran
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 2nd Feb 2007 03:32
It's really better to combine all menus into one function rather than separate functions. You can use select/case commands for each menu and use the functions ability to return a variable to determine what the current menu is.

Also the command "draw to front" makes sure that all 2D drawing is done last so it's on top of any 3D drawing.



Login to post a reply

Server time is: 2024-11-26 21:37:00
Your offset time is: 2024-11-26 21:37:00