trying to add a menu system to platformer starter kit, any help?
by Mohammad Adam · in Torque X Platformer Kit · 08/18/2010 (6:40 pm) · 10 replies
torque x has a menu or gui, i want to add this to the platformer starter kit but dont know how, can anyone help me, i am really new to torque X, :)
#2
08/19/2010 (10:56 pm)
Thank you Aaron.
#3
08/20/2010 (4:54 am)
Check out the GUI in the platformer startkit. I think its called GUI.cs,, and look at how its initialized, you should be able to create a menu based on that. Thats the best way to get started.
#4
Going to review and try the following: Splash Screen Tutorial and NEW: Intro to the Torque X GUI
08/22/2010 (7:57 pm)
@Mohammad: The TDN has Tutorials and Guides that have GUI documentation.Going to review and try the following: Splash Screen Tutorial and NEW: Intro to the Torque X GUI
#5
09/02/2010 (5:41 pm)
Im trying to merge the standard GUI that comes with Torque with the PSK. It might work it might not Has anybody tried?
#6
Just wondered if anyone had progressed any further on this? I have been working on this for a few hours and have managed to get a menu working based on Henry's Gamekit code, Dro Sarhadian's splash screen tutorial and the PSK demo.
BUT! When I load the scene file my menu doesn't disappear. It has something to do with the GUI and passing control. I'm not a coder so this is taking a lot of time and I'm brand new to Torque 2D too ;-)
This is the code, the demo uses a GUI.cs file which defines the structure and functionality of the HUD seen in the PlatformerDemo.
I'm not sure if this can be integrated? A proper code monkey is needed!
09/03/2010 (9:59 am)
Hey,Just wondered if anyone had progressed any further on this? I have been working on this for a few hours and have managed to get a menu working based on Henry's Gamekit code, Dro Sarhadian's splash screen tutorial and the PSK demo.
BUT! When I load the scene file my menu doesn't disappear. It has something to do with the GUI and passing control. I'm not a coder so this is taking a lot of time and I'm brand new to Torque 2D too ;-)
This is the code, the demo uses a GUI.cs file which defines the structure and functionality of the HUD seen in the PlatformerDemo.
private void On_Option1_Select()
{
// Game.Instance.SoundGroup.PlaySound("menuClick");
Game.Instance.SceneLoader.Load(@"data\levels\demo_modified.txscene");
// set the parallax manager's target object
T2DSceneCamera camera = TorqueObjectDatabase.Instance.FindObject<T2DSceneCamera>("Camera");
ParallaxManager.Instance.ParallaxTarget = camera;
_sceneGraph = camera.SceneGraph as T2DSceneGraph;
GUIStyle playStyle = new GUIStyle();
GUISceneview play = new GUISceneview();
play.Name = "PlayScreen";
play.Style = playStyle;
play.Camera = camera;
GUICanvas.Instance.SetContentControl(play);
PlatformerDemoGUI.Instance.GUI.Folder = GUICanvas.Instance;
}I'm not sure if this can be integrated? A proper code monkey is needed!
#7
return Vector2.Distance(_actor.Position, (SceneObject.SceneGraph.Camera as T2DSceneCamera).Position);
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="PlatformerDemo"
StackTrace:
at GarageGames.Torque.PlatformerDemo.DrillActorComponent._getDistanceToPlayer() in C:\Users\Tim\Documents\Visual Studio 2008\Projects\Torque X Platformer Demo (3.1.5)1\Torque X Platformer Demo (3.1.5)1\Game\DrillActorComponent.cs:line 56
at GarageGames.Torque.PlatformerDemo.DrillActorComponent._OnRegister(TorqueObject owner) in C:\Users\Tim\Documents\Visual Studio 2008\Projects\Torque X Platformer Demo (3.1.5)1\Torque X Platformer Demo (3.1.5)1\Game\DrillActorComponent.cs:line 72
at GarageGames.Torque.Core.TorqueComponentContainer._RegisterComponents(TorqueObject owner)
at GarageGames.Torque.Core.TorqueObject.OnRegister()
at GarageGames.Torque.T2D.T2DSceneObject.OnRegister()
at GarageGames.Torque.T2D.T2DAnimatedSprite.OnRegister()
at GarageGames.Torque.Core.TorqueObjectDatabase.Register(TorqueObject obj)
at GarageGames.Torque.PlatformerFramework.SpawnPointComponent.Spawn() in C:\Users\Tim\Documents\Visual Studio 2008\Projects\Torque X Platformer Demo (3.1.5)1\Torque X Platformer Demo (3.1.5)1\PlatformerFramework\SpawnPointComponent.cs:line 230
at GarageGames.Torque.PlatformerFramework.ProximitySpawnPointComponent.ProcessTick(Move move, Single elapsed) in C:\Users\Tim\Documents\Visual Studio 2008\Projects\Torque X Platformer Demo (3.1.5)1\Torque X Platformer Demo (3.1.5)1\PlatformerFramework\SpawnPointComponent.cs:line 408
at GarageGames.Torque.Sim.ProcessList._TickObjects(Single tickSec)
at GarageGames.Torque.Sim.ProcessList.AdvanceTick(Single floatMS)
at GarageGames.Torque.XNA.TorqueEngineComponent._UpdateSim(String eventName, Single elapsed)
at GarageGames.Torque.Core.TorqueEvent`1._Trigger(Delegate d)
at GarageGames.Torque.Core.TorqueEventManager._TriggerEvent(TorqueEventBase ev)
at GarageGames.Torque.Core.TorqueEventManager.MgrProcessEvents()
at GarageGames.Torque.Core.TorqueEventManager.ProcessEvents()
at GarageGames.Torque.XNA.TorqueEngineComponent.Update(GameTime gameTime)
at Microsoft.Xna.Framework.Game.Update(GameTime gameTime)
at GarageGames.Torque.PlatformerDemo.Game.Update(GameTime gameTime) in C:\Users\Tim\Documents\Visual Studio 2008\Projects\Torque X Platformer Demo (3.1.5)1\Torque X Platformer Demo (3.1.5)1\Game\Game.cs:line 172
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.Run()
at GarageGames.Torque.PlatformerDemo.GameStarter.Main(String[] args) in C:\Users\Tim\Documents\Visual Studio 2008\Projects\Torque X Platformer Demo (3.1.5)1\Torque X Platformer Demo (3.1.5)1\Game\Main.cs:line 24
InnerException:
This seems to be common theme throughout these forums and it looks as if no one had managed to find a solution to it, here are a few posts which go into the issue.
www.torquepowered.com/community/forums/viewthread/82169
www.torquepowered.com/community/forums/viewthread/78557
www.torquepowered.com/community/forums/viewthread/69082
www.torquepowered.com/community/forums/viewthread/71490
www.torquepowered.com/community/forums/viewthread/73882
www.torquepowered.com/community/forums/viewthread/76056
It seems we need a concerted community effort to resolve this issue!
09/03/2010 (10:39 am)
I've been playing with this again and am now suffering from:return Vector2.Distance(_actor.Position, (SceneObject.SceneGraph.Camera as T2DSceneCamera).Position);
System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="PlatformerDemo"
StackTrace:
at GarageGames.Torque.PlatformerDemo.DrillActorComponent._getDistanceToPlayer() in C:\Users\Tim\Documents\Visual Studio 2008\Projects\Torque X Platformer Demo (3.1.5)1\Torque X Platformer Demo (3.1.5)1\Game\DrillActorComponent.cs:line 56
at GarageGames.Torque.PlatformerDemo.DrillActorComponent._OnRegister(TorqueObject owner) in C:\Users\Tim\Documents\Visual Studio 2008\Projects\Torque X Platformer Demo (3.1.5)1\Torque X Platformer Demo (3.1.5)1\Game\DrillActorComponent.cs:line 72
at GarageGames.Torque.Core.TorqueComponentContainer._RegisterComponents(TorqueObject owner)
at GarageGames.Torque.Core.TorqueObject.OnRegister()
at GarageGames.Torque.T2D.T2DSceneObject.OnRegister()
at GarageGames.Torque.T2D.T2DAnimatedSprite.OnRegister()
at GarageGames.Torque.Core.TorqueObjectDatabase.Register(TorqueObject obj)
at GarageGames.Torque.PlatformerFramework.SpawnPointComponent.Spawn() in C:\Users\Tim\Documents\Visual Studio 2008\Projects\Torque X Platformer Demo (3.1.5)1\Torque X Platformer Demo (3.1.5)1\PlatformerFramework\SpawnPointComponent.cs:line 230
at GarageGames.Torque.PlatformerFramework.ProximitySpawnPointComponent.ProcessTick(Move move, Single elapsed) in C:\Users\Tim\Documents\Visual Studio 2008\Projects\Torque X Platformer Demo (3.1.5)1\Torque X Platformer Demo (3.1.5)1\PlatformerFramework\SpawnPointComponent.cs:line 408
at GarageGames.Torque.Sim.ProcessList._TickObjects(Single tickSec)
at GarageGames.Torque.Sim.ProcessList.AdvanceTick(Single floatMS)
at GarageGames.Torque.XNA.TorqueEngineComponent._UpdateSim(String eventName, Single elapsed)
at GarageGames.Torque.Core.TorqueEvent`1._Trigger(Delegate d)
at GarageGames.Torque.Core.TorqueEventManager._TriggerEvent(TorqueEventBase ev)
at GarageGames.Torque.Core.TorqueEventManager.MgrProcessEvents()
at GarageGames.Torque.Core.TorqueEventManager.ProcessEvents()
at GarageGames.Torque.XNA.TorqueEngineComponent.Update(GameTime gameTime)
at Microsoft.Xna.Framework.Game.Update(GameTime gameTime)
at GarageGames.Torque.PlatformerDemo.Game.Update(GameTime gameTime) in C:\Users\Tim\Documents\Visual Studio 2008\Projects\Torque X Platformer Demo (3.1.5)1\Torque X Platformer Demo (3.1.5)1\Game\Game.cs:line 172
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.Run()
at GarageGames.Torque.PlatformerDemo.GameStarter.Main(String[] args) in C:\Users\Tim\Documents\Visual Studio 2008\Projects\Torque X Platformer Demo (3.1.5)1\Torque X Platformer Demo (3.1.5)1\Game\Main.cs:line 24
InnerException:
This seems to be common theme throughout these forums and it looks as if no one had managed to find a solution to it, here are a few posts which go into the issue.
www.torquepowered.com/community/forums/viewthread/82169
www.torquepowered.com/community/forums/viewthread/78557
www.torquepowered.com/community/forums/viewthread/69082
www.torquepowered.com/community/forums/viewthread/71490
www.torquepowered.com/community/forums/viewthread/73882
www.torquepowered.com/community/forums/viewthread/76056
It seems we need a concerted community effort to resolve this issue!
#8
09/03/2010 (12:36 pm)
I have been having the same problem. I spent 3 hours trying to solve the problem but alas no solution. One thing we can try and do is merge the standard Torque GUI and the PSK. What would need to happen is all of the game play initialization would have to be in th GUIplay. It would be good if the community could solve this. :)
#9
I have made some progress, see this thread:
www.torquepowered.com/community/forums/viewthread/120185
09/03/2010 (3:45 pm)
@JohnI have made some progress, see this thread:
www.torquepowered.com/community/forums/viewthread/120185
#10
YourGUI.Instance.GUI.Folder = new TorqueFolder();
eh, seems to work for me. The underlying principle being that random folder will not result in your GUI being rendered, until next time you put it in the GUICanvas.Instance.
(Also, before looking at the camera properties, make sure the camera != null)
09/03/2010 (5:19 pm)
try this... does your GUI have a get instance method, and a public property for the base parent? If so, if it is similar to the platformerdemo GUI, try this..YourGUI.Instance.GUI.Folder = new TorqueFolder();
eh, seems to work for me. The underlying principle being that random folder will not result in your GUI being rendered, until next time you put it in the GUICanvas.Instance.
(Also, before looking at the camera properties, make sure the camera != null)
Torque 3D Owner Aaron Scovel