Game Development Community

Is there something wrong with my methods file?

by Orion the Hunter · in Torque Game Builder · 12/21/2012 (9:34 am) · 5 replies

Hello,

I'm trying to spawn a black ball that falls on the ground and then bounces but all it does it stays floating at its spawn point without falling. It doesn't even autorotate like I told it to.

//-----------------------------------------------------------------------------
// Platformer Starter Kit
// Copyright (C) Phillip O'Shea
//  
// Drill Methods - All of the methods that makes a Drill a Drill.
//-----------------------------------------------------------------------------

function BoolClass::onAddToScene( %this, %scenegraph )
{
    Parent::onAddToScene( %this );

    %this.DisableGravity = false;

%puppet = %this.getAnimationPuppet();
%puppet.autoRotation = 90;

    if ( isObject( DrillHeadTemplate ) )
    {
        %this.DrillHead = new t2dSceneObject()
        {
            config     = DrillHeadTemplate;
            scenegraph = %scenegraph; //%this.scenegraph would probably work here as well

            FlipX = %this.FlipX;
        };
        %this.DrillHead.addToScene(%scenegraph);
        %this.DrillHead.mount( %this );
    }
}

function BoolClass::onRemove( %this )
{
    if ( isObject( %this.DrillHead ) )
    {
        %this.DrillHead.safeDelete();
    }
}

function BoolClass::onRespawn( %this, %dAmount, %srcObject )
{
    %this.DisableGravity = false;
}

function BoolClass::onDeath( %this, %dAmount, %srcObject )
{
$pref::points = $pref::points + 100;

    %this.DisableGravity = true;

    if ( isObject( %this.DrillHead ) )
    {
        %this.DrillHead.safeDelete();
    }

    %TextSprite = new t2dTextObject()
    {
        SceneGraph    = Scenewindow2D.getSceneGraph();
      canSaveDynamicFields = "1";
      Position = %This.Position;
      size = "14.758 4.920";
      text = "+100";
      font = "OCR A Std";
      wordWrap = "1";
      hideOverflow = "1";
      textAlign = "Left";
      lineHeight = "4.91946";
      aspectRatio = "1.15903";
      lineSpacing = "0";
      characterSpacing = "0";
      autoSize = "0";
      fontSizes = "42";
      BlendColor = "0 0 1 1";
      bilinearFilter = "1";
      snapToInteger = "0";
      noUnicode = "0";
         hideOverlap = "0";
         mountID = "794";
         snapToIntegerPos = "0";
      _behavior0 = "ScaleBehavior	xWidthMin	0.001	yWidthMin	0.001	xWidthMax	15	yWidthMax	5	DeleteObject	1";
      ConstantForce = "0 -50";

    };

}

function BoolClass::onLanded( %this, %platformObject )
{
%this.owner.jumpUp();
}

function BoolClass::resolveEnemyCollision( %ourObject, %theirObject, %normal )
{
    // Resolve the collisions differently for different ai types
    switch$ ( %theirObject.ActorType )
    {
        case "Drill" : %OurObject.Direction.X *= -1; break;
        case "Snake" : %OurObject.Direction.X *= -1;
    }
}

function BoolClass::onWallCollision( %this, %wall, %normal )
{
    %this.Direction.X = %normal.X;
}

Something wrong here? BTW, I am EXECing the Bool's file... I have a data block and everything.

#1
12/21/2012 (11:42 am)
This may seem like a stupid question but have you added the datablock
to the objects scripting panel?
#2
12/21/2012 (1:12 pm)
Is BoolClass the black balls class?
I don't see anywhere in there that makes any object (excluding the TextObject) move in a vertical direction except possibly the jumpUp function.
#3
12/21/2012 (1:59 pm)
If physics is on and the collision is set to bounce(in TGB) there will be no code in the method. Gravity would cause the ball to fall, collision would cause the ball to bounce.
#4
12/21/2012 (5:00 pm)
I decided the whole BoolClass thing probably was crewing up the source so I replaced it with "BoolEnemyClass." Let me show you everything that references to "Bool" and please tell me if it's not working.

BTW, I got this error report along with a crash when I atempted to load...

/Users/Torque/Desktop/HandDrawn 1.0 (Mac)/game/gameScripts/BoolMethods.cs Line: 8 - parse error
>>> Advanced script error report.  Line 8.
>>> Some error context, with ## on sides of error halt:
// Platformer Starter Kit

// Copyright (C) Phillip O'Shea

//  

// Drill Methods - All of the methods that makes a Drill a Drill.

//-----------------------------------------------------------------------------



function BoolEnemyClass::onAddToScene( %this, %scenegraph )

##{##

    Parent::onAddToScene( %this );



    %this.DisableGravity = false;



%puppet = %this.getAnimationPuppet();

%puppet.autoRotation = 90;



    if ( isObject( DrillHeadTemplate ) )

    {

        %this.DrillHead = new t2dSceneObject()

        {

            config     = DrillHeadTemplate;
>>> Error report complete.

Here is "Bool's" datablock:

datablock t2dSceneObjectDatablock( BoolEnemyActorTemplate )
{
    Class             = "BoolEnemyClass";
    ActorType         = "BoolEnemy";
    
    Size              = "10.000 10.000";
    Layer             = "2";
    CollisionPolyList = "-0.354 -0.123 0.354 -0.123 0.354 0.764 -0.354 0.764";
    _Behavior0        = "AIControllerBehavior\tAIType\tDrill";
    MaxMoveSpeed      = 20;
    GroundAccel       = 1000;
    GroundDecel       = 1000;
    
    AllowRespawn      = false;
    DeathTimeOut      = 500;
};

Do you guys see any mess-ups?
#5
12/22/2012 (8:04 am)
The error halt seems to show you are missing a { in the code at the start of the function.