Page 1 of 1

Level disappears when I load my game?

PostPosted: Mon Apr 01, 2013 11:30 pm
by TeraPoison
I was using it and creating a title screen. when you click start and it loads the game it makes the stage disappear and the character will fall into the void . How do I fix this? ALSO how do I make the title screen game and ending screen all on one game and export it and make it work? Thanks guys you all are the best! 8)

Re: Level disappears when I load my game?

PostPosted: Mon Apr 01, 2013 11:33 pm
by Hblade
It's a small bug when loading ged files

Re: Level disappears when I load my game?

PostPosted: Mon Apr 01, 2013 11:35 pm
by TeraPoison
is there a way to fix it? also how do I do the last part?

Re: Level disappears when I load my game?

PostPosted: Tue Apr 02, 2013 12:08 am
by skydereign
TeraPoison wrote:is there a way to fix it?

It doesn't happen in the exported version of the game, but it is a major inconvenience when building your game. I usually recommend not using multiple ged files for your levels, this being one of the reasons.
TeraPoison wrote:ALSO how do I make the title screen game and ending screen all on one game and export it and make it work?

You would need to use some variable in a save file. That way when you load the main menu, you check the value of the variable, and if it is one for instance, you move the view to the ending screen (also setting it back to zero and saving). So whenever you want to display the end screen from a level, you set the variable, call saveVars, and then call LoadGame.

Re: Level disappears when I load my game?

PostPosted: Tue Apr 02, 2013 12:10 am
by TeraPoison
that went straight over my head dude. im sorry im really new to this.

Re: Level disappears when I load my game?

PostPosted: Tue Apr 02, 2013 12:22 am
by skydereign
TeraPoison wrote:that went straight over my head dude. im sorry im really new to this.

It was meant to be a cursory explanation, since I didn't know your experience with gE. If you want the title screen file to serve as both the title screen, and the end game screen, the game will need to know which one it is loading. The only way to transfer data between two game files is through save files of some sort. By default you probably want the title screen executable to load up the title screen, because that is what you show when you start the game.

Now the game will always start in the same way, so you need to write some code at the beginning of the menu screen to check which screen to show. Either the main menu by default, or if the variable is set, show the end game screen. The following is generally how it would work. end_screen would be a variable in the save group menu_type. If you aren't sure how to use save groups, search the forums for saveVars/loadVars.
view -> Create Actor -> Script Editor
Code: Select all
loadVars("menu_type", "menu_type");
if(end_screen==1)
{
    y=1000; // move the view to where the end game screen is shown
}

Re: Level disappears when I load my game?

PostPosted: Tue Apr 02, 2013 12:25 am
by TeraPoison
I need all 3 to work together

Re: Level disappears when I load my game?

PostPosted: Tue Apr 02, 2013 12:55 am
by skydereign
Ah, I missed the mention of the game in it as well. If you are going with the multiple ged method, then all you need to really worry about is the LoadGame function. Create your title menu as an executable. This game should have some way of loading your level files (which will be exported as .dat files) using the LoadGame functions. Usually you would put the LoadGame in a button click. Your game files should have some way of returning to the menu usually, and when you beat the game, have a call to LoadGame for your end game file (also a .dat). It's pretty basic idea, since all you need to do is call LoadGame for the different files when you need to transition between them.

Re: Level disappears when I load my game?

PostPosted: Tue Apr 02, 2013 1:12 am
by TeraPoison
After I export the game how does the title screen and the end load?

Re: Level disappears when I load my game?

PostPosted: Tue Apr 02, 2013 1:18 am
by skydereign
You export the title screen as an executable. You can then open the executable, and it loads the title screen (because that is what the executable is of). You export your end screen and game levels as .dat files, which are just files that the title screen will load. All you need to do to load up the other parts of the game is to use LoadGame. For example, you have a button in the title screen game with the following code.
Code: Select all
LoadGame("level1.dat");

Clicking that would then try to load the level1.dat file. As soon as it loads, the game will now be playing the level1 file, instead of the title screen. Remember, the title screen is the file you load first, and should be the only executable. That way the player can't load any level they want, and play your game out of order.