Arska134 Posted July 27, 2012 Share Posted July 27, 2012 Hello! I am trying to do menu and game in different scenes, but some problems comes up... For a first boot of game menu loads as it should. I select "Start game" and game itself loads as i should. But when i press ESC (to go back to main menu) it gives me "Null framewerk". I tried to clear all entities from world with "ClearWorld()" function. If KeyHit(KEY_ESCAPE)=True Then clearworld() Goto menu EndIf Game keeps running still. Now i try to select "Start game" and game crashes. Without clearworld() it gets back to game, but player model is invisible and old player model stands there. So how should i reset my game probably? Quote Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax Link to comment Share on other sites More sharing options...
Arska134 Posted August 1, 2012 Author Share Posted August 1, 2012 Really? Nobody? Quote Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax Link to comment Share on other sites More sharing options...
macklebee Posted August 1, 2012 Share Posted August 1, 2012 read through this: http://www.leadwerks.com/werkspace/topic/903-lua-error/#entry8035 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Arska134 Posted August 1, 2012 Author Share Posted August 1, 2012 Looks like that it's creating new controller, but it isn't creating player model again. I tried to use "FreeEntity(playerModel)", but it still not creating new one when entering game again. I pushen some barrels around in my scene and then tried to go back to main menu and then start new game, but barrels are in place where is pushed them. I am not currently using clearworld() because it crashes the game. If i understand right you said in that thread that when loading new scene it should reset framework too. Quote Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax Link to comment Share on other sites More sharing options...
macklebee Posted August 2, 2012 Share Posted August 2, 2012 are you telling it to free the controller/character then recreating a new character/controller? i said it appears to be releasing everything in the world... but i had not tried it with anything but simple examples. It sounds like you just need to use ResetFramework(), reload the scene, and then recreate the character/controller... At this point without you posting your code or example code there really isn't much i can do but guess at what you are doing... if you want help, its always best to post some code so people can actually see what you are doing... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Arska134 Posted August 2, 2012 Author Share Posted August 2, 2012 Here is some "code" to explain what is happening. *Load everything which i need only load ones (engine and etc...)* #menu *Load scene for main menu* repeat *menu selection stuff* forever *Load scene for game itself* *Create player controller* *Create player model* repeat if keyhit(KEY_ESCAPE) then goto menu endif forever So if i press 'escape' it jumps back to menu scene loading part. What should i do before jumping there? I no need game scene no more when going back to main menu. I need to reset/delete it somehow. Now when i am going back to game it continues previous scene of game, but not creating new character model, and old one is still in scene where i left it last time. Quote Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax Link to comment Share on other sites More sharing options...
macklebee Posted August 3, 2012 Share Posted August 3, 2012 free the character/controller ResetFramework() Reload the scene recreate the character/controller that seems to work just fine in the example i am trying... but i am also assuming you are adding the character/controller via the code and its not something that is placed in the scene via an object script... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
flachdrache Posted August 3, 2012 Share Posted August 3, 2012 I do not exactly "destroy/delete" structures but reInit them with scene values ... e.g. the camera gets places at an "info_player" which is fetched on scene load. // -- // Prepare App for new sceneLoad if( KeyHit(KEY_F5) ) { ResetFramework(); playerIndex01.~cController(); playerIndex01.SetCamera( GetLayerCamera( _layer_main ) ); playerIndex01.CreatePlayer(); scene.~cScene(); scene.Load( "abstract::SceneParaTropique_GTownCamp.sbx" ); // add camera from scene PositionEntity( playerIndex01.GetCamera(), scene.GetCameraPos() ); RotateEntity( playerIndex01.GetCamera(), scene.GetCameraRot() ); // add controller from scene camera PositionEntity( playerIndex01.GetPlayer(), scene.GetCameraPos() ); } else if( KeyHit(KEY_F6) ) { ResetFramework(); playerIndex01.~cController(); playerIndex01.SetCamera( GetLayerCamera( _layer_main ) ); playerIndex01.CreatePlayer(); scene.~cScene(); scene.Load( "abstract::SceneParaTropique_GTownBlank.sbx" ); // add camera from scene PositionEntity( playerIndex01.GetCamera(), scene.GetCameraPos() ); RotateEntity( playerIndex01.GetCamera(), scene.GetCameraRot() ); // add controller from scene camera PositionEntity( playerIndex01.GetPlayer(), scene.GetCameraPos() ); } Which means on start of the game and only the menu comes up (going back to menu in your case) i have a default.sbx scene loaded with a controller in the background. I do this to keep some "game assets" around which keeps load times somewhat shorter and for the menu background world. If a "CreatePlayer" has to add a controllable player or just the camera could be fetched with Set/GetKey for init_spawnpoint Vs. player_spawnpoint ... Load/Save belongs to "CreatePlayer" then imo. a little dodgy to explane but hth ... Quote AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3 zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5 Xxploration FPS in progress ... Link to comment Share on other sites More sharing options...
Arska134 Posted August 5, 2012 Author Share Posted August 5, 2012 Almost working now. If KeyHit(KEY_ESCAPE)=True Then freeentity(playerModel) freeentity(player) resetframework() Goto menu EndIf Thats what i did when escape is pressed. Now it goes to menu. (what is oddly very blurry) When i go back to game it loads everything nicely. Next thing what i see my player character falling, because scene isn't loaded. So can somebody explain me why it's not loading scene? Quote Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax Link to comment Share on other sites More sharing options...
macklebee Posted August 5, 2012 Share Posted August 5, 2012 uh, are you reloading the scene? LoadScene("abstract::NameOfTheScene.sbx") Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
Arska134 Posted August 5, 2012 Author Share Posted August 5, 2012 uh, are you reloading the scene? LoadScene("abstract::NameOfTheScene.sbx") Yes i am reloading the scene. Quote Windows 7 Ultimate | Intel Core i7 930 @ 2.80 ghz | Nvidia GeForce GTX 560 | Leadwerks 2.5 | Blitzmax Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.