Scene Reloaded
by Zilla · in Torque X Platformer Kit · 08/26/2008 (1:05 pm) · 9 replies
There are different suggestions in the forums how to change scenes:
www.garagegames.com/mg/forums/result.thread.php?qt=69082
www.garagegames.com/mg/forums/result.thread.php?qt=71490
www.garagegames.com/mg/forums/result.thread.php?qt=73882
www.garagegames.com/mg/forums/result.thread.php?qt=76056
I tried all of them in the Platformer Kit but none of them seems to work.
Does anybody have a Platformer Demo with different levels?
www.garagegames.com/mg/forums/result.thread.php?qt=69082
www.garagegames.com/mg/forums/result.thread.php?qt=71490
www.garagegames.com/mg/forums/result.thread.php?qt=73882
www.garagegames.com/mg/forums/result.thread.php?qt=76056
I tried all of them in the Platformer Kit but none of them seems to work.
Does anybody have a Platformer Demo with different levels?
#2
core_game_assets.txscene (create it by starting with the default level_01.txscene and deleting everything)
level1.txscene (the current level_01.txscene)
level2.txscene (the new changed level_01.txscene file for level 2)
In the Game.cs, BeginRun() method, load the core_game_assets.txscene and the level1.txscene. Then, in your level change code, only unload your level1.txscene and load the level2.txscene. I haven't had a chance to try this yet, but I think the theory is sound. Maybe someone can give it a shot and report back.
John K.
09/08/2008 (10:46 pm)
The problem is that SceneLoader.Unload() obliterates EVERYTHING in the folder specified by the scene file and that includes materials, scenegraph, camera, all of it. So, I think we need to split up the .txscene file and just unload the parts we dont want. So.... create somthing like likecore_game_assets.txscene (create it by starting with the default level_01.txscene and deleting everything)
level1.txscene (the current level_01.txscene)
level2.txscene (the new changed level_01.txscene file for level 2)
In the Game.cs, BeginRun() method, load the core_game_assets.txscene and the level1.txscene. Then, in your level change code, only unload your level1.txscene and load the level2.txscene. I haven't had a chance to try this yet, but I think the theory is sound. Maybe someone can give it a shot and report back.
John K.
#3
What i done was:
Create a new method in Game class;
09/09/2008 (2:50 pm)
I've had a go at that and got this:---- DEBUG ASSERTION FAILED ----
---- Assert Short Message ----
Mounter and mountee must either both be registered or neither registered.
---- Assert Long Message ----
at Assert.Fatal(Boolean condition, String message)
at T2DSceneObject.Mount(T2DSceneObject mountee, String linkPointName, Vector2 offset, Single rotationOffset, Boolean ownedByMount)
at PlayerDragonActorComponent._mountCamera() C:PlayerDragonActorComponent.cs(142)
at PlayerDragonActorComponent._PostRegister() C:Actors\Player\PlayerDragonActorComponent.cs(191)
at TorqueComponentContainer._PostRegisterComponents()
at TorqueObject.OnRegister()
at T2DSceneObject.OnRegister()
at TorqueObjectDatabase.Register(TorqueObject obj)
at TorqueSceneData._LoadObjects(List'1 list)
at TorqueSceneData.Load(String filename, List'1 extraAssemblies)
at TorqueSceneData.Load(String filename)
at SceneLoader.Load(String sceneFileName)
at Game.myUnLoader() C:Game.cs(216)
at PepperCollectibleComponent._confirmPickup(T2DSceneObject ourObject, T2DSceneObject theirObject, ActorComponent actor) C:PepperCollectibleComponent.cs(30)
at CollectibleComponent._onEnter(T2DSceneObject ourObject, T2DSceneObject theirObject, T2DCollisionInfo info) C:CollectibleComponent.cs(36)
at DirectionalTriggerComponent.OnCollision(T2DSceneObject ourObject, T2DSceneObject theirObject, T2DCollisionInfo info, T2DResolveCollisionDelegate& resolve, T2DCollisionMaterial& physicsMaterial) C:\PlatformerFramework\DirectionalTriggerComponent.cs(49)
at T2DPhysicsComponent._ResolveCollisions(List'1 list)
at T2DPhysicsComponent.ProcessTick(Move move, Single dt)
at ProcessList._TickObjects(Single tickSec)
at ProcessList.AdvanceTick(Single floatMS)
at TorqueEngineComponent._UpdateSim(String eventName, Single elapsed)
at TorqueEvent'1._Trigger(Delegate d)
at TorqueEventManager._TriggerEvent(TorqueEventBase ev)
at TorqueEventManager.MgrProcessEvents()
at TorqueEventManager.ProcessEvents()
at TorqueEngineComponent.Update(GameTime gameTime)
at Game.Update(GameTime gameTime)What i done was:
Create a new method in Game class;
public void myUnLoader()
{
SceneLoader.UnloadLastScene();
SceneLoader.Load(@"data\levels\level_01.txscene");
}Added a line too begin run://load the content
SceneLoader.Load(@"data\levels\Content_Loader.txscene");
// load the test level
SceneLoader.Load(@"data\levels\level_01.txscene");Also to trigger all this, in the peppercomponent:protected override bool _confirmPickup...
if (actor is PlayerDragonActorComponent...
Game.Instance.myUnLoader();It basically starts to load the second level and has problems with the camera here:PlayerDragonActorComponent camera.Mount(_actor, String.Empty, new Vector2(0, -1), 0.0f, true);
#4
Seems like a clever idea because I remember that I once was able to load a new scene OVER the last one without errors. I am still a bit busy with my Dream-Build-Play entry but if I win and get a contract for XBox Live (ha-ha-ha...) I will have to implement different scenes in my game and I will try this approach.
09/11/2008 (1:44 am)
John,Seems like a clever idea because I remember that I once was able to load a new scene OVER the last one without errors. I am still a bit busy with my Dream-Build-Play entry but if I win and get a contract for XBox Live (ha-ha-ha...) I will have to implement different scenes in my game and I will try this approach.
#5
John K.
09/11/2008 (8:49 pm)
I'm not laughing - I think you have a really great shot at winning it! When you're making the big Xbox LIVE money, remember us little people ;)John K.
#6
You are very kind :-)
To thank you, I (accidentally...) ordered two copies of your book:
One through amazon and one from Garage Games... ;-)
All the best!
09/12/2008 (1:00 am)
John,You are very kind :-)
To thank you, I (accidentally...) ordered two copies of your book:
One through amazon and one from Garage Games... ;-)
All the best!
#7
John K.
09/13/2008 (8:49 am)
Amazon has a great return policy with instructions on their site. I've accidentally double-ordered items too ;)John K.
#8
03/10/2010 (1:32 am)
Did anyone ever figure this out.. I still cant seem to find a solid answer to how to change levels with the platformer x kit..
#9
I am starting to think the platformer kit is not fit for purpose and should be withdrawn from sale
03/21/2010 (9:02 am)
I am still waiting for a solution to this as well.I am starting to think the platformer kit is not fit for purpose and should be withdrawn from sale
Torque Owner Vishal Bhanderi
I've tried loading a level too, but every method I try, I get:
A first chance exception of type 'System.ObjectDisposedException' occurred in Microsoft.Xna.Framework.dll
Cannot access a disposed object.
Object name: 'Texture2D'.
I guess I need to keep the textures and stuff.