Game Development Community

Documentation Error

by James Bond · in Torque Game Builder · 12/20/2006 (1:23 pm) · 4 replies

I am trying to follow the supplied documentation that comes with TGB, however I have run into a problem with the Fish Demo tutorial :
"
function FishClass::onWorldLimit(%this, %mode, %limit)
{
   switch$ (%limit)
   {
      case "left":
         %this.setLinearVelocityX(20);
         %this.setFlipX(false);
      
      case "right":
         %this.setLinearVelocityX(-20);
         %this.setFlipX(%flipX)(true);
   }
}


We need to add a call to both the "left" and "right" responses. This call will set the fish's Y position in a random number between the top of the level and just above the ground. Make your function look like this.

function FishClass::onWorldLimit(%this, %mode, %limit)
{
   switch$ (%limit)
   {    
      case "left":
         %this.setLinearVelocityX(20);
         %this.setFlipX(false);
      case "right":
         %this.setLinearVelocityX(-20);
         %this.setFlipX(true);
    }
}
Code Sample 6.1.1
"
....As you can see this is supposed to make the fish reach the world limits, then come back across the screen at a different location on the Y axis. The code is identical apart from one white line was removed. I did a search on the forums, but can't find what to do.

Anyone have any ideas?
-Thanks in advance.

#1
12/20/2006 (2:21 pm)
Try this:

%newY = getRandom(-35, 25);
%this.setPositionY(%newY);

and you should use code formatting.

These are the tags (take out the .'s)
[.code]
[./code]
#2
12/20/2006 (2:22 pm)
Thanks Chris Labombard. This is the code that is missing from the documentation, I can carry on now.
#3
12/27/2006 (10:06 am)
Thanks for posting this issue with the docs... I just fixed that in our internal version :) That one slipped by me, if you have any further issues feel free to post them.
#4
12/27/2006 (11:29 am)
;) no problems.