Game Development Community

Torque X 2D - Knowledge Base (Problems & Solutions)

by Josh Neider · in Torque X 2D · 05/25/2010 (8:43 am) · 7 replies

In the process of making Zombie Sniper HD and previously testing out Torque X 2D I came across roadblocks that prevented further progress until I found the solution. I figured I would share those problems & solutions in an organized fashion and in doing so maybe start this thread that will allow others to do the same.

I will present the title of the problem upper casing key words and in bold font. I will then provide a brief problem description and then a solution.

Background & Particles Disappear When Lots on Screen
Problem Description: Objects in the scene begin disappearing randomly or after a lot of objects are loaded / spawned on the screen.
Solution:
T2DSceneCamera cam = TorqueObjectDatabase.Instance.FindObject<T2DSceneCamera>("Camera");
cam.FarDistance = 10000f;
www.torquepowered.com/community/forums/viewthread/81173

When a Scene Loads It Consumes a Lot of Memory – Code 4 on Xbox
Problem Description: Scenes take a long time to load and load on the PC however they Code 4 on the Xbox. In the Windows task manager the game consumes a lot of memory when the scene loads.
Solution:All of the following solutions may help:

  1. Use the Level Ripper originally created by Matthew Hoesterey! It can be found here: www.torquepowered.com/community/forums/viewthread/105507 By default a scene will load every asset located in the torque project – this rips unused (in the scene) assets out of the scenes.
  2. DXT Compress your images! Check out how here: www.torquepowered.com/community/forums/viewthread/80517
GUI Alignment is a Pain in the Butt
Problem Description: When using different resolutions nothing in the GUI scenes are showing up in the correct places.
Solution:Target your Xbox games to bee 1280x720. Put the following in your torqueSetting.xml file:
<XboxGraphicsManagerSettings>  
    <PreferMultiSampling>false</PreferMultiSampling>  
    <UseDisplaySizeForBackbuffer>false</UseDisplaySizeForBackbuffer>  
    <PreferredBackBufferHeight>720</PreferredBackBufferHeight>  
    <PreferredBackBufferWidth>1280</PreferredBackBufferWidth>  
</XboxGraphicsManagerSettings>
www.torquepowered.com/community/forums/viewthread/113901

Audio is Not Being Compressed – Making the .ccgame File Huge
Problem Description: The .ccgame file is growing the actual size of my audio wave files when I add new ones.
Solution: Create a new Compression Preset in XACT and then apply that to your Wave Bank

How Can I Debug on the Xbox!?
Problem Description:When debug and push out to the Xbox it is deployed however I have to exit Game Studio Connect to play the game and cannot debug the code.
Solution: Having the GS Connect run on the Xbox right click the Xbox copy of the game. A contextual menu shows up: there select Debug -> Start New Instance. This will run the game in debug mode on the Xbox. (thanks Pino)
www.torquepowered.com/community/forums/viewthread/115153

How do I Check if the Game is in TrialMode?
Problem Description:I would like to limit game content or show a purchase screen if the game is in trial mode, how do I check for trial mode?
Solution:Check out John's post here www.torquepowered.com/community/blogs/view/17453

But here is what you need to check:
if( Guide.IsTrialMode )

Also, you can simulate trial mode for testing by using this (I just put it in my Game.cs BeginRun() method:

Guide.SimulateTrialMode = true;

Be sure to comment it out when you're not testing :)

How do I use Guide.ShowMarketplace
Problem Description: When I try to use the Guide.ShowMarketplace I’m getting an exception.
Solution: Check out this blog by John: www.torquepowered.com/community/blogs/view/17453
using Microsoft.Xna.Framework.GamerServices;
In the Game.cs file, find your BeginRun() method and add the gamer services component.

Where do I set the Xbox Thumbnail
Problem Description:How do I change the thumbnail/icon for my game on the Xbox?
Solution: The image must be a PNG file sized to 64x64 pixels and less than 16KB file size. You set the thumbnail in the project properties view (make sure you go to the Xbox 360 Copy properties), at the bottom of the Application tab.
www.torquepowered.com/community/blogs/view/17453

How do I check to make sure a Signed In Player can Make Purchases?
Problem Description: If I use the Guide.ShowMarketplace I first need to make sure the player signed in can make purchase, how do I do this?
Solution: This is how I did it using AllowPurchaseContent property:

Edit: I updated the code to work if the controller is not signed in.

if (Guide.IsTrialMode)
{
    
    try
    {
        SignedInGamer gamer = Gamer.SignedInGamers[Game.Instance.GameState.PlayerIndex];
        
        if (gamer != null)
        {
            if (SignedInGamer.SignedInGamers[Game.Instance.GameState.PlayerIndex].Privileges.AllowPurchaseContent)
            {
                Guide.ShowMarketplace(Game.Instance.GameState.PlayerIndex);
            }
            else
            {
                Guide.ShowSignIn(1, true);

            }
        }
        else
        {
            Guide.ShowSignIn(1, true);
        }
    }
    catch
    {

    }

}

How do I Pause my Game?
Problem Description How do I pause my game, also how do I make sure it pauses when guides show up or a controller is disconnected?
Solution: The main code you need is this:
Game.Instance.Engine.GameTimeScale = 0.0f;
I have that in a BeginPause() method in my Game.cs file so I can pretty much call it from anywhere. I also use the GameTimeScale to speed the game up to increase difficulty so in my EndPause() method I set the GameTimeScale to a variable that I control throughout the game:
Game.Instance.Engine.GameTimeScale = Game.Instance.GameState.GameTimeScale;
Here's the code I use to deal with controllers and guides - it's actually sitting in a GameComponent (that's loaded when the game is loaded) in the ProcessTick method:
if (!Game.Instance.IsActive | Guide.IsVisible | !GamePad.GetState(Game.Instance.GameState.PlayerIndex).IsConnected)
{
   if (!Game.Instance.GameState.GuidePaused)
   {
      Game.Instance.GameState.Paused = true;
      Game.Instance.GameState.GuidePaused = true;
      Game.Instance.BeginPause();
   }
}
else
{
   if (Game.Instance.GameState.GuidePaused)
   {
      Game.Instance.GameState.Paused = false;
      Game.Instance.GameState.GuidePaused = false;
      Game.Instance.EndPause();
   }
}

Game has Black Flickering Lines
Problem Description: The game has black flickering lines.
Solution: This means that there are too few objects on the screen so the frame rate is way too fast. You can fix this by setting the engine to 60 FPS (Thanks Pino - this code is in Pino's community project):

/// <summary> 
/// Set the Engine to fixed time step at the standard of 60FPS 
/// This will avoid the flickering of a few lins on top 
/// of the screen while in menu and other slow fps scenes 
/// </summary> 
public static void SetEngineTimeStepTo60FPS() 
{ 
   ProcessList.Instance.UseInterpolation = false; 
   TorqueEngineComponent.Instance.Game.IsFixedTimeStep = true; 
   TorqueEngineComponent.Instance.Game.TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 16); 
} 
        
/// <summary> 
/// Set the Engine to get as much FPS as possible (no fixed time step) 
/// </summary> 
public static void SetEngineTimeStepToFree() 
{ 
   ProcessList.Instance.TickMS = 0; 
   ProcessList.Instance.UseInterpolation = false; 
   TorqueEngineComponent.Instance.Game.IsFixedTimeStep = false; 
}

I noticed that my GuiSplash screens didn't work right with it set to 60 FPS so I set it to 60 FPS after the splash screens.

Code in the ProcessTick() Method Not Running
Problem Description: I have a component that I have put code in the ProcessTick method however the code isn't running, why?
Solution: You need to add the following to the _OnRegister method:

ProcessList.Instance.AddTickCallback(Owner, this);

How do I get sound working?
Problem Description: Running into issues getting sound working.
Solution: Darthuvius did a nice tutorial here: sites.google.com/site/soyouwanttomakeanarenashooter/tutorial-4---aural-delights

Also, Henry has posted a couple useful forum posts, here is one of them: www.torquepowered.com/community/forums/viewthread/113621

I was recently setting up a new project and I was banging my head against the wall... my SoundGroup kept coming back null... I finally realized from the above referenced tutorial I was missing this in the torquesettings.xml file!:

<EnableAudio>true</EnableAudio>
 <AudioGlobalSettingsFile>data/sounds/ArenaShooterSounds.xgs</AudioGlobalSettingsFile>

How to schedule a function to run in a given time?
Problem Description: I'd like to specify a time and have a delay before someFunction() is run.
Solution: Check out this forum post by John Kanalakis: www.torquepowered.com/community/forums/viewthread/68706

This worked great for me. The MyScheduledFuntion needs to be just as it is in the forum post with those params (at least that's how I got it working).

#1
05/25/2010 (12:27 pm)
Maybe one of us should write a book? ;)
#2
05/25/2010 (12:36 pm)
Probably you should, since a lot of the answers came from your posts. Hope you don't mind being mentioned in our credits :) Thanks!
#3
05/25/2010 (12:49 pm)
This is awesome. Thanks Josh.

Adding to the TDN community links.
#4
05/25/2010 (12:57 pm)
goodstuff
#5
05/27/2010 (9:28 am)
Nice
#6
05/27/2010 (6:15 pm)
www.torquepowered.com/community/forums/viewthread/94779
this post helped me for when i couldnt bind input commands to an existing inputmap. Something to consider
#7
09/16/2011 (10:50 am)
Problem: After using AnimateZoom some, most, or all animations flicker or vanish completely. Animations stop flickering or become visible again after the camera zoom is returned to its original value. Note: I have tested all my animations without any background objects and the problem still exists.

Solution? It appears that cloned animations are not effected by this glitch. Clone All Animations?