How do I create a Score on iTorque 2D
by Claudio Torres · in iTorque 2D · 05/09/2011 (4:15 pm) · 11 replies
It is a pity iTorque do not have documentation. It looks a great product, but I am having a hard time trying to find hints, bits and pieces to try to build my first iPad game. I am spending important hours of development trying to figure out simple things.
GUI Editor for example is different from TGB, and even the GUI tutorials for TGB are useless.
Anyway, before decide to go for another engine and loose my $99 bucks, I will give a try. Shame on you Garage Games staff.
I am trying to create a score on a game. Ridiculous, but I can find a single example how to do that.
The text editor do not work. The fonts looks terrible low res.
Can anyone give a piece of code on how to create a Score (with background and colored fonts) for a iTorque game level?
Can anyone give a hint on how to build a startup menu (with background and HiRes text) for a iTorque game?
GUI Editor for example is different from TGB, and even the GUI tutorials for TGB are useless.
Anyway, before decide to go for another engine and loose my $99 bucks, I will give a try. Shame on you Garage Games staff.
I am trying to create a score on a game. Ridiculous, but I can find a single example how to do that.
The text editor do not work. The fonts looks terrible low res.
Can anyone give a piece of code on how to create a Score (with background and colored fonts) for a iTorque game level?
Can anyone give a hint on how to build a startup menu (with background and HiRes text) for a iTorque game?
About the author
Electronic Engineer, MSc on System, Software Developer, Digital Marketing Consultant. Today I managing Torres Studios, a new Game and Entertainment Studio focus on create innovative iPad and XBOX 360 Games.
#2
You mean that I must create a set of own fonts, in png, adjust all the possible options (including leave wast space between 0's at the left, or create a algorithm to reduce the display width and so on), and create a function to convert integers to this sprite staff?.
It doesn't sound to me a good solution. It is feasible, but hardcoded and time consuming.
What I am looking for is a standard Score, using real fonts, and a number presentation scheme. A real score.
05/09/2011 (6:17 pm)
OK. It should be a solution, but it sounds hardcoded. You mean that I must create a set of own fonts, in png, adjust all the possible options (including leave wast space between 0's at the left, or create a algorithm to reduce the display width and so on), and create a function to convert integers to this sprite staff?.
It doesn't sound to me a good solution. It is feasible, but hardcoded and time consuming.
What I am looking for is a standard Score, using real fonts, and a number presentation scheme. A real score.
#3
Inside the .t2s level file the declaration of the textobject will look something like the example below. Try changing the line stating the font size to something higher. That usually works for me.
new t2dTextObject() {
canSaveDynamicFields = "1";
class = "";
Position = "57.997 105.703";
size = "13.438 5.000";
text = "your text here";
font = "Arial";
wordWrap = "0";
hideOverflow = "1";
textAlign = "Left";
lineHeight = "5";
aspectRatio = "1";
lineSpacing = "0";
characterSpacing = "0";
autoSize = "1";
fontSizes = "10";
textColor = "1 1 1 1";
bilinearFilter = "0";
snapToInteger = "0";
noUnicode = "0";
BlendIgnoreTextureAlpha = "0";
filter = "0";
hideOverlap = "0";
integerPrecision = "0";
mountID = "28";
};
05/10/2011 (12:51 am)
Regarding the low res on textobject, this can adjusted if you open the actual .t2d level file with a text editor program. Locate the code for the textObject and you will also find a line that says what font size is being used. For some reason this value is often set very low, which causes the low res when looking at the textobject in torque.Inside the .t2s level file the declaration of the textobject will look something like the example below. Try changing the line stating the font size to something higher. That usually works for me.
new t2dTextObject() {
canSaveDynamicFields = "1";
class = "";
Position = "57.997 105.703";
size = "13.438 5.000";
text = "your text here";
font = "Arial";
wordWrap = "0";
hideOverflow = "1";
textAlign = "Left";
lineHeight = "5";
aspectRatio = "1";
lineSpacing = "0";
characterSpacing = "0";
autoSize = "1";
fontSizes = "10";
textColor = "1 1 1 1";
bilinearFilter = "0";
snapToInteger = "0";
noUnicode = "0";
BlendIgnoreTextureAlpha = "0";
filter = "0";
hideOverlap = "0";
integerPrecision = "0";
mountID = "28";
};
#4
To display text in iTGB there is the class t2dTextObject.
Regarding the documentation, the best place for reference is on your installation folder /documentation. Click the "Reference" item in the menu and you'll get access to a very detailed API description.
Regarding the "how to do this", the best place to find the answer is in these forums. If you do a search you will most likely have it explained by someone already.
True, Torque has a bit of a learning curve. Here's some advice from my learning experience:
1) Use Torsion, a Torque script IDE with debugger. It works in Windows only.
2) Avoid the Editor and try to write everything in code. The Editor may be a great tool, but if you're starting, it may not be the best way to see what is happening and why, since it generates all the code for you.
3) Write the "logic" part of your program in C++ and do only the rendering with script. The tutorials at the Torque Developer Network
show how to do this
tdn.garagegames.com/wiki/TDN_Home
Once you get up to speed, iTGB (or TGB) is a great product to work with, so don't give up just yet :-)
05/10/2011 (2:28 am)
@ClaudioTo display text in iTGB there is the class t2dTextObject.
Regarding the documentation, the best place for reference is on your installation folder /documentation. Click the "Reference" item in the menu and you'll get access to a very detailed API description.
Regarding the "how to do this", the best place to find the answer is in these forums. If you do a search you will most likely have it explained by someone already.
True, Torque has a bit of a learning curve. Here's some advice from my learning experience:
1) Use Torsion, a Torque script IDE with debugger. It works in Windows only.
2) Avoid the Editor and try to write everything in code. The Editor may be a great tool, but if you're starting, it may not be the best way to see what is happening and why, since it generates all the code for you.
3) Write the "logic" part of your program in C++ and do only the rendering with script. The tutorials at the Torque Developer Network
show how to do this
tdn.garagegames.com/wiki/TDN_Home
Once you get up to speed, iTGB (or TGB) is a great product to work with, so don't give up just yet :-)
#5
Here's an implementation of a score using t2dTextObject. To use this class:
1) Open the Editor, create a new project, and choose Save As..."Untitled.t2d". Exit the Editor
2) Edit this file and change the first line to
You can also change the camera size. I usually use
a multiple of the iPhone portrait aspect ratio. Then create a new file "hello_world.cs" and save it in the /scripts folder.
Make this call in main.cs
The contents of this file are :
This will display your score, incremented every 2 seconds.
If you're working in Windows, the purpose of this call
is to have a window that "matches" the iPhone dimensions but that is larger than the default 320x480
05/10/2011 (4:24 am)
@ClaudioHere's an implementation of a score using t2dTextObject. To use this class:
1) Open the Editor, create a new project, and choose Save As..."Untitled.t2d". Exit the Editor
2) Edit this file and change the first line to
%levelContent = new t2dSceneGraph( HelloWorldSceneGraph )
You can also change the camera size. I usually use
cameraSize = "64 96";
a multiple of the iPhone portrait aspect ratio. Then create a new file "hello_world.cs" and save it in the /scripts folder.
Make this call in main.cs
exec("./scripts/hello_world.cs");The contents of this file are :
function HelloWorldSceneGraph::OnAdd(%this)
{
if( $platform $= "windows" )
setScreenMode( 640, 960, 32, false );
%this.score = %this.MakeTextObject();
%this.the_score = 0;
%this.schedule( 2000, DoScore );
}
function HelloWorldSceneGraph::MakeTextObject( %this )
{
%obj = new t2dTextObject()
{
scenegraph = %this;
text = "";
textAlign = "Center";
font = "Times New Roman Bold";
hideOverflow = false;
autoSize = true;
Visible = true;
};
%fontsize = 120;
%obj.removeAllFontSizes();
%obj.addFontSize( %fontsize );
%obj.LineHeight = %fontsize;
%obj.setBlendColor( 0.0, 1.0, 0.0, 1.0 );
%obj.setSize( 7 );
%obj.text = "Hello iTGB World ";
return %obj;
}
function HelloWorldSceneGraph::DoScore(%this)
{
%this.score.text = %this.the_score;
%this.schedule_id = %this.schedule( 2000, DoScore );
%this.the_score ++;
}This will display your score, incremented every 2 seconds.
If you're working in Windows, the purpose of this call
if( $platform $= "windows" ) setScreenMode( 640, 960, 32, false );
is to have a window that "matches" the iPhone dimensions but that is larger than the default 320x480
#6
More to the point, I have never used the GUI system for the iPhone so can't comment on its differences. However there are many alternatives, these are the two I like the idea of most:
- Overlay an iOS view, allowing you to create the GUI in Xcode's visual editor.
- Place a second scene window into the mainScreen.gui object and place a t2dTextObject here. If you look in the Bugs section or perform a forum search you'll instantly see that there's a known editor bug regarding text quality and fixes have been posted.
05/10/2011 (6:05 am)
@Claudio I think you're jumping the gun by a long way to suggest that you've wasted any money on iTGB. It still remains the best visual game making tool out there for the iPhone, we're very lucky that it is currently $99 and not the previous price of several thousand dollars. To insult the staff before even asking for advice shows terrible manners.More to the point, I have never used the GUI system for the iPhone so can't comment on its differences. However there are many alternatives, these are the two I like the idea of most:
- Overlay an iOS view, allowing you to create the GUI in Xcode's visual editor.
- Place a second scene window into the mainScreen.gui object and place a t2dTextObject here. If you look in the Bugs section or perform a forum search you'll instantly see that there's a known editor bug regarding text quality and fixes have been posted.
#7
We are expanding our documentation team, so we will have the resources to cover more of the engines and increase the tutorials. As the others mentioned, t2dTextObject is the best solution for displaying text (like a score). The known issue with its resolution will be addressed in an official release, but for now the posted answers are spot on.
For my own projects, I completely avoid the GUI Editor. I find there is a lot more flexibility using sprites. I'm sorry you are hitting some walls. As you can see, the engine is progressing and the iT2D community is eager to help you along. I'm spinning up development for the next release today, so you will see me more present in the forums for a while. I will be happy to help when I can.
05/10/2011 (6:29 am)
I will be the first to admit the GUI system itself has issues for iTorque 2D. We have about five bugs logged against the system in our bug tracker, none of which I'm looking forward to fixing. You can use it, but I agree the docs on the GUI Editor are skimpy. What is available for TGB is exactly the same as iTorque 2D, so there is some information out there. We are expanding our documentation team, so we will have the resources to cover more of the engines and increase the tutorials. As the others mentioned, t2dTextObject is the best solution for displaying text (like a score). The known issue with its resolution will be addressed in an official release, but for now the posted answers are spot on.
For my own projects, I completely avoid the GUI Editor. I find there is a lot more flexibility using sprites. I'm sorry you are hitting some walls. As you can see, the engine is progressing and the iT2D community is eager to help you along. I'm spinning up development for the next release today, so you will see me more present in the forums for a while. I will be happy to help when I can.
#8
We always pay the learning curve price, but we expect on a paid, and today even on an Open Source Free Tool, to have the documentation ready with the software. I always assume if a software exists, there are bugs. But is really hard to try to dig on the forum for basics or put basic questions all the time.
Even, remove the GUI Editor from iTorque, and write down a "tutorial for Score" is better than keep a tool that do not work and have no documentation. There are no profiles on iTorque GUI Editor and the interface is different from TGB. Why keep a tool that is useless?
I am trying hard to get out with my first iTorque iPad Game, but my concern is that I am hitting walls on very basics because there is no documentation covering it.
05/10/2011 (7:21 am)
Michael, thanks for your answer. If I can give you a suggestion, as a newbee on TGB but a 25 years experience programmer: Documentation is everything in a software.We always pay the learning curve price, but we expect on a paid, and today even on an Open Source Free Tool, to have the documentation ready with the software. I always assume if a software exists, there are bugs. But is really hard to try to dig on the forum for basics or put basic questions all the time.
Even, remove the GUI Editor from iTorque, and write down a "tutorial for Score" is better than keep a tool that do not work and have no documentation. There are no profiles on iTorque GUI Editor and the interface is different from TGB. Why keep a tool that is useless?
I am trying hard to get out with my first iTorque iPad Game, but my concern is that I am hitting walls on very basics because there is no documentation covering it.
#9
As I mentioned in my last post, we are already increasing the documentation team. David MB just joined the team and is actually going to be the overseer of the documentation effort. Now I have someone holding me accountable down to word for each doc I write. We are also interviewing a rock start tech writer this week.
Anytime I need additional help to deliver on a doc task, the new owners and C team (Eric and Dexter) give me full reigns to contract work and assemble a team. This is a great change of pace. Even the engineers are voluntarily writing docs and handing them off to me. Granted, a lot of this recent effort has been focused on Torque 3D, but you better believe I'm going to push for this to continue on to iTorque 2D development.
Sorry, I know that is kind of a rant with me dangling mythical candy. My intent is not to promise anything, but to reveal how much documentation really means to GarageGames. Specific to your needs, I will look at the tutorial plans for iTorque 2D and see if we can squeeze in a doc for the GUI Editor.
05/10/2011 (7:51 am)
Quote:Documentation is everything in a software.Believe me, you are preaching to the choir. You will be hard pressed to find anyone on the site trumpeting the importance of documentation more than myself. In no way am I making an excuse, but my expectations and effort for documentation has not really been consistently backed by the necessary resources.
As I mentioned in my last post, we are already increasing the documentation team. David MB just joined the team and is actually going to be the overseer of the documentation effort. Now I have someone holding me accountable down to word for each doc I write. We are also interviewing a rock start tech writer this week.
Anytime I need additional help to deliver on a doc task, the new owners and C team (Eric and Dexter) give me full reigns to contract work and assemble a team. This is a great change of pace. Even the engineers are voluntarily writing docs and handing them off to me. Granted, a lot of this recent effort has been focused on Torque 3D, but you better believe I'm going to push for this to continue on to iTorque 2D development.
Sorry, I know that is kind of a rant with me dangling mythical candy. My intent is not to promise anything, but to reveal how much documentation really means to GarageGames. Specific to your needs, I will look at the tutorial plans for iTorque 2D and see if we can squeeze in a doc for the GUI Editor.
#10
Don't Use it! :)
I jest, but I do think a doc for creating UI elements would be much more beneficial than a doc for using the GUI Editor.
- Explain why you choose to use sprites and how you wld recommend using them.
- Would love to hear more on how Alistair is setting up an overlay for an iOS view
- Then of course you can cover some gui editor stuff too, just be clear on the limitations.
Thats my 2 cents. I know you guys have plenty on your plate as it is. Cheers for tackling these issues and the documentation head on.
05/10/2011 (9:22 am)
Here is the doc for the GUI editor:Don't Use it! :)
I jest, but I do think a doc for creating UI elements would be much more beneficial than a doc for using the GUI Editor.
- Explain why you choose to use sprites and how you wld recommend using them.
- Would love to hear more on how Alistair is setting up an overlay for an iOS view
- Then of course you can cover some gui editor stuff too, just be clear on the limitations.
Thats my 2 cents. I know you guys have plenty on your plate as it is. Cheers for tackling these issues and the documentation head on.
#11
I'm writing a behavior and it will good for me to have %this.owner.setFontSize or something that look like it.
05/11/2011 (1:19 pm)
There's a way to set textObject's font size without modify the level with a text editor?I'm writing a behavior and it will good for me to have %this.owner.setFontSize or something that look like it.
Torque Owner rennie moffat
Renman3000
What I do is create sprites, of numbers in Illustrator. and use those as oppose to text.
Then simple have a score function. Within that function I add to a variable so...
function thisBehavior::score(%this) { $score = $score + 1; ///%this.scoreNumberObject is the imageMap of numbers I use to visually represent my score %this.scoreNumberObject.setFrame($score); }And that's it.