Game Development Community

The Breakout Tutorial - Part Four

by Tetraweb · in Torque Game Builder · 03/30/2008 (4:13 pm) · 22 replies

Part Four of The Breakout Tutorial is now live. This thread is intended for discussion, questions and problems specifically related to Part Four.

Thanks,
Greg
The Breakout Tutorial
Page «Previous 1 2
#1
04/07/2008 (4:46 pm)
I can't get the ScoreboardGui to show up in the game. I'm not sure what I'm doing wrong, either. I've checked the code for mistakes I might have made while typing it out, copied your code examples and pasted them in, but it still won't show up.

Any tips or suggestions?
#2
04/09/2008 (4:56 am)
A few things to check.

Did you exec it in? I'm sure you did, but it never hurts to check again.

Any errors in the console when you Canvas.pushDialog ?

Last, check your ScoreboardGui.gui file and make sure the beginning of it still has this:
if(!isObject(GuiTextW22Profile)) new GuiControlProfile (GuiTextW22Profile : GuiTextProfile)
	{
	   fontSize = 22;
	   fontColor = "220 220 220";
	   fontType = "JuneBug";
	};

I was seeing TGB 1.7 and 1.7.2 overwriting the .gui files sometimes and 'cleaning' them up without being asked.

Please let me know, thanks.

Greg
#3
04/09/2008 (12:31 pm)
Yep it's in my exec script. One thing I did noticed is that for all the other execs you use the ./ notation but for the gui you use the ~/ notation. But even if I switch it to ./ I have the same problem.

No errors in the console.

Yes I do have that in the beginning of my ScoreboardGui.gui file. I compared it to mainScreen.gui which starts out a little differently:

//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiControl(mainScreenGui) {
// rest of code here
};

//--- OBJECT WRITE END ---

I don't see how the comment would make a difference but the fact that when it makes a new GuiControl it assigns it to a variable is interesting to me.

Anyway, here's my entire ScoreboardGui.gui:
if(!isObject(GuiTextW22Profile)) new GuiControlProfile (GuiTextW22Profile : GuiTextProfile)
{
	fontSize = 22;
	fontColor = "220 220 220";
	fontType = "JuneBug";
};

new GuiControl(ScoreboardGui)
{
	canSaveDynamicFields = "0";
	Profile = "GuiModelessDialogProfile";
	HorizSizing = "right";
	VertSizing = "bottom";
	border = 0;
	Position = "0 0";
	Extent = "200 40";
	MinExtent = "8 2";
	canSave = "1";
	Visible = "1";
	hovertime = "1000";
	modal="false";
	
	new GuiTextCtrl()
	{
		canSaveDynamicFields = "0";
		Profile = "GuiTextW22Profile";
		HorizSizing = "right";
		VertSizing = "bottom";
		Position = "20 740";
		Extent = "96 20";
		MinExtent = "8 2";
		canSave = "1";
		Visible = "1";
		hovertime = "1000";
		text = "SCORE:";
		maxLength = "1024";
	};
   
	new GuiTextCtrl(ScoreboardGuiScore)
	{
		canSaveDynamicFields = "0";
		Profile = "GuiTextW22Profile";
		HorizSizing = "right";
		VertSizing = "bottom";
		Position = "116 740";
		Extent = "520 20";
		MinExtent = "8 2";
		canSave = "1";
		Visible = "1";
		hovertime = "1000";
		text = "0";
		maxLength = "1024";
	};
};

An interesting thing to note is that I even opened up TGB's GUI Editor and tried to place it manually but when I opened it, it told me "You have loaded a Gui file that was created before this version. It has been loaded but you must open it manually from the content list dropdown." Not sure what that means, but when I look at my ScoreboardGui.gui file nothing has been changed.

Any other ideas?
#4
04/09/2008 (5:46 pm)
That %guiContent = in the .gui file is new to 1.7, and that is why the GUI Editor thinks it was from an earlier version. Everything else about the GUI is compatible though.

Are you on 1.7.2 on WinXP or something else? I'll take another look; then I guess the next step is to ask you if you can zip up your folder and email it to me. Thanks

**Edit**
We can narrow down the problem. In the profile change
fontType = "JuneBug";
to
fontType = "Arial";

Then if you run it and you see the Score: 0 in Arial, we know the problem is with the JuneBug font.
Keep me posted, thanks.
**Edit**

Greg
#5
04/09/2008 (7:01 pm)
Yes I'm using 1.7.2 on Windows XP SP2.

Quote:We can narrow down the problem. In the profile change
fontType = "JuneBug";
to
fontType = "Arial";

Then if you run it and you see the Score: 0 in Arial, we know the problem is with the JuneBug font.
I thought about that too. Especially after I opened it up in the GUI Builder and it showed lines outlining it, but nothing was visible. Changing it to Arial doesn't make anything appear.

I'll check your profile for an e-mail address.
#6
04/09/2008 (7:36 pm)
If you would, you can zip your project and send it to me at gregt@tetraweb.com .

***edit**
Got your zip and replied via email.

Greg
#7
04/10/2008 (11:38 am)
I already sent you an e-mail with the solution I found (user error) but decided to report it here in case anyone else runs into this problem.

Somehow in the very first part of the tutorial I missed the step in setting up the scene to change the Design Resolution to 1024x768. Instead it was set to 800x600. So when the script places the Y coordinate of the score text at 740, it's 140 pixels off the bottom of the screen.

Make sure you've got the correct Design Resolution!

Thanks for the help! Now I'll continue with the tutorial.
#8
04/10/2008 (3:26 pm)
Tying it Together

Quote:We are still checking the getCount of the balls SimSet, and now the fist thing we do is play the lostball sound that we set up earlier. Next we call the reduceLifeIcons function in our if statement. Remember, that function returns true at the end if there are still life icons left, and false it there are not.
A couple of highlighted typos.

A Tweak

First of all, throughout this entire section you sometimes refer to the function as simpleFadein and sometimes as simpleFadeIn.

Another thing is, why don't you just use setBlendAlpha and getBlendAlpha and skip the extra steps of including color? For example:

function t2dSceneObject::simpleFadein(%this)
{
   if (!%this.fadingin)
   {
      // begin fadein
      %this.setBlendAlpha("0.00");
      %this.visible = true;
      %this.fadingin = true;
      %this.schedule(60, "simpleFadein");
   } else {
      %currentalpha = %this.getBlendAlpha());
      %currentalpha += 0.06;
      if (%currentalpha > 0.95) {
         // finished fading in
         %this.setBlendAlpha("1");
         %this.fadingin = false;
      } else {
         %this.setBlendAlpha(%currentalpha);
         %this.schedule(60, "simpleFadein");
      }
   }
}

I tested it and it works. Of course, this only makes sense if we don't modify this function later to mess around with the color part of the blending.

One More Thing

Quote:Now we have an AudioDescription to use for looping audio, and you can see that we have set the volume to 75%, quieter than the sound effectes audio description.
Typo highlighted.

It's shaping up to become a pretty impressive tutorial/demo! Thanks again for the tutorial and the wide range of topics that are covered in it!
#9
06/23/2008 (12:22 am)
Ok - just finished tutorial 4, and I have a "little" problem where I lose a ball by missing it, then the moment I get a new ball to replace it I lose that one as well (before I've even had a chance to launch it), and sometimes the same happens to the next one I get to replace that one!

Losing one ball actually causes me to lose THREE balls and my ship.

With a few echos, I can see the lostTrig::onEnter function is being run, the ball is being removed from the SimSet, I have more lives left so a new ball is loaded in baseClass::unfreeze, and then lostTrig::onEnter is run again straight away.

My trigger is set up as follows:
Trigger - Enter Callback is checked; Stay and Leave Callbacks are both unchecked.
Collision - Send and Receive Collision are checked, Send and Receive Physics, and Callback are unchecked. Everything else is as per default.
Scene Object - Position "0.000 84.500" and Size "200.000 17.000"

When a new ball is created, it's at position "0.000 62.147999" so doesn't seem to be overlapping the trigger on creation.

No errors when compiling, and everything else seems to be working ok.
#10
06/25/2008 (7:36 pm)
I'm having a similar, maybe even the very same problem as Shaz. I've completed the tutorial 4, but at the first check point I had an issue, but no errors were reported upon starting the debug.

After losing or missing the ball, the ship blows up and then all my lives are lost as well. So I went back through everything and found a couple of ommitions. Ran it again and the ship still blew up, froze and lost all my lives. At this point I thought maybe something later in Tut. 4 would fix this. I completed the tutorial and still run into the same issue, producing numerous repeating errors as follows:

game/gameScripts/game.cs (68): Unable to find object: '0' attempting to call function 'safeDelete'

Set::getObject index out of range.

game/gameScripts/lifeicons.cs (49): Unable to find object: '-1' attempting to call function 'loseLife'

game/gameScripts/lifeicons.cs (51): Unable to find object: '-1' attempting to call function 'isAlive'

DEAD

Like I said, these errors are repeating while in-game as it freezes up. So I double checked everything in Tut. 4 again and everything is in correct place, no missing files, etc.

Mike
#11
06/26/2008 (4:48 am)
Shaz and Mike, If you would, you can zip your project and send it to me at gregt@tetraweb.com .

Greg
#12
06/27/2008 (5:54 pm)
On its way now. Sorry about the file size - 5MB.
#13
06/27/2008 (7:51 pm)
I had that exact same problem myself! For some reason the event keeps being sent from the trigger when the new ball is spawned. I wonder if the default position for the ball is somewhere in the trigger and then it gets moved 1 frame later when it gets mounted to the base. I haven't dug into this hypothesis yet, but I figured I would throw it out there to see if anyone else has gone down that path.

For the meantime, I was able to bypass the problem by using the Torquescript function "setEnterCallback." I basically disable the trigger in the onEnter function and then re-enable it after I create a new ball. I know this hack will not work once I have more than one ball active on the screen at once, but this at least works so I can keep moving. If someone wants specifics on how I did this, just ask in teh forum and I will post the details. I would not consider it a "fix" and I am 99% sure it will cause issues later in the tutorial.

Greg, if you do find a solution, please post it here. I am really curious now. :)

Thanks-
Mark
#14
07/06/2008 (1:30 pm)
Greg, haven't heard back from you yet. Wondering if you had a chance to look at my files.

Mike
#15
08/01/2008 (3:53 pm)
@Shaz, @Mark or @DeVry, did you ever figure it out?

Whatever the problem is, it's random and unpredictable. Sometimes a ball will appear and mount like normal, and sometimes it will blink out immediately. I haven't been able to switch it on and off yet.
#16
08/01/2008 (5:11 pm)
@Ray, no, I sent my project off to Greg but haven't heard back yet. I suspect the sleepless nights associated with a new baby in the house might have something to do with that ;)

I just checked, and the issue is not resolved with 1.7.4 (I was hopeful, because there was a trigger error in 1.7.3 but alas....)
#17
08/02/2008 (12:47 pm)
@Shaz, thanks for the reply. I'm going to keep investigating this.

Yeah, I think we're all inclined to give Greg a break right now. Some things are even more important than Torque. :)
#18
08/03/2008 (7:31 pm)
I've been investigating this a little more. All of my trigger settings are the same as what @Shaz listed. I've measured the lifetime of the ball, the ball's Y position when it is spawned, and the ball's Y position when it is lost. Here's what my console.log shows:

New ball created at y=64.819
The live tile count is 9
Loading compiled script C:/blahblahwhatever/  (It's the scoreboard.gui, actually).
This ball died at y=75.3003 after 44.0323 seconds.
New ball created at y=64.819
This ball died at y=74.4916 after 4.8962 seconds.
New ball created at y=64.819
This ball died at y=50.8877 after 0.0639992 seconds.
New ball created at y=64.819
This ball died at y=76.1963 after 3.4561 seconds.
New ball created at y=64.819
This ball died at y=50.8877 after 0.064003 seconds.
New ball created at y=64.819
This ball died at y=50.8877 after 0.0639992 seconds.
New ball created at y=64.819
This ball died at y=50.8877 after 0.0639954 seconds.
New ball created at y=64.819
This ball died at y=50.8877 after 0.064003 seconds.
New ball created at y=64.819
This ball died at y=76.4505 after 80.7621 seconds.
DEAD

As the output shows, the balls that live a long and happy life die a natural death when they enter the trigger area, at approximately y=75. The balls that blink in and out of existence appear (from the numbers) to jump up 14 Y units before they disappear, but observation during gameplay doesn't show them moving at all.

Update, Aug 8: Something about the fade-in effect makes it worse -- so it happens every time a new ball appears.
#19
08/24/2008 (7:05 pm)
For some reason the background image is not loading, i checked the console and it said something about back1ImageMap being 'invalid'
#20
08/24/2008 (9:49 pm)
For some reason the background image is not loading, i checked the console and it said something about back1ImageMap being 'invalid'
Page «Previous 1 2