Player trigger event
by Stephen Stalker · in Torque X 2D · 05/11/2009 (10:22 pm) · 3 replies
I've been searching high and low to find some comprehensive info on how to create a trigger component to attach to a scene object to unload my scene and load a new one when the player collides with the sceneobject. The closest thing I could find was www.garagegames.com/community/forums/viewthread/80873
Can someone please help?
Here's what I have in my .cs file thus far...
Can someone please help?
Here's what I have in my .cs file thus far...
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using GarageGames.Torque.Platform;
using GarageGames.Torque.Core;
using GarageGames.Torque.Sim;
using GarageGames.Torque.GUI;
using GarageGames.Torque.MathUtil;
using GarageGames.Torque.T2D;
namespace StarterGame2D
{
[TorqueXmlSchemaType]
public class ScenechangerComponent : TorqueComponent
{
class GuiSplashScreen : GUISplash, IGUIScreen
{
public GuiSplashScreen()
{
// create the Style for our splash ad
GUISplashStyle splashStyle = new GUISplashStyle();
splashStyle.FadeInSec = 1; // black to image 1 seconds
splashStyle.FadeOutSec = 1; // image to black 1 seconds
splashStyle.FadeWaitSec = 3; // still image for 3 seconds
splashStyle.Bitmap = @"data\images\LoadingScreenSplash";
splashStyle.PreserveAspectRatio = true;
// set some info for this control
Name = "GuiSplashScreen";
Style = splashStyle;
Size = new Vector2(1024, 768);
OnFadeFinished = OnSplashFinished;
}
public void OnSplashFinished()
{
//Load New Scene
Game.Instance.SceneLoader.Unload(@"data\levels\levelData.txscene");
Game.Instance.SceneLoader.Load(@"data\levels\levelData2.txscene");
//create a renderable canvas for the scene
GUIStyle stylePlayGui = new GUIStyle();
GUISceneview playGui = new GUISceneview();
playGui.Style = stylePlayGui;
//switch over to the new canvas
GUICanvas.Instance.SetContentControl(playGui);
}
}
}
}
#2
05/17/2009 (7:56 pm)
Awesome! That's exactly what I'm wanting. I look forward to checking out the code.
#3
www.garagegames.com/community/forums/viewthread/74103
Brian
05/18/2009 (2:26 pm)
This thread would probably be useful for you to check out as well:www.garagegames.com/community/forums/viewthread/74103
Brian
Torque 3D Owner Josef Rogovsky
It's part of a demo game I wrote to show off features of TX 2D.
I was planning on porting it to TX v3 this weekend.
I'll post the entire project for download when I finish updating it. But if I don't finish it this weekend I'll at least post the level loader component code for you.