Game Development Community

2d demo fish problem

by Matthew Roeske · in Torque Game Engine · 08/17/2007 (7:27 pm) · 3 replies

I have been playing around with the 2d game builder demo and can't get my fish to move down.

All other keys work but the "s". i even tried binding it to a differnt key. But nothing. Any suggestions?

Here is the code:

function PlayerFish::onLevelLoaded(%this,%scenegraph) {

$FishPlayer = %this;

moveMap.bindCmd(keyboard, "w", "fishPlayerUp();", "fishPlayerUpStop();");
moveMap.bindCmd(keyboard, "s", "fishPlayerDown();", "fishPlayerDownStop();");
moveMap.bindCmd(keyboard, "a", "fishPlayerLeft();", "fishPlayerLeftStop();");
moveMap.bindCmd(keyboard, "d", "fishPlayerRight();", "fishPlayerRightStop();");
}

// Move
function fishPlayerUp() {
$FishPlayer.setLinearVelocityY (-15);
}
function fishPlayerDown(){
FishPlayer.setLinearVelocityY (30);
}
function fishPlayerLeft() {
$FishPlayer.setLinearVelocityX (-30);
}
function fishPlayerRight() {
$FishPlayer.setLinearVelocityX (30);
}



// Stop
function fishPlayerUpStop() {
$FishPlayer.setLinearVelocityY {0);
}
function fishPlayerDownStop() {
$FishPlayer.setLinearVelocityY (0);
}
function fishPlayerLeftStop() {
$FishPlayer.setLinearVelocityX (0 );
}
function fishPlayerRightStop() {
$FishPlayer.setLinearVelocityX (0 );
}

About the author

Recent Threads

  • 2d demo fish problem

  • #1
    08/17/2007 (8:01 pm)
    Your problem is right here...


    // Move
    function fishPlayerUp() {
    $FishPlayer.setLinearVelocityY (-15);
    }
    function fishPlayerDown(){
    FishPlayer.setLinearVelocityY (30); <---------- ADD A $ in front of the FishPlayer
    }
    function fishPlayerLeft() {
    $FishPlayer.setLinearVelocityX (-30);
    }
    function fishPlayerRight() {
    $FishPlayer.setLinearVelocityX (30);
    }

    GL
    #2
    08/17/2007 (8:31 pm)
    Another thing that will cause problems at some point is that you have a curly brace instead of a rounded bracket in the fishPlayerUpStop function.

    function fishPlayerUpStop() {
    $FishPlayer.setLinearVelocityY {0);
    }

    should be

    function fishPlayerUpStop() {
    $FishPlayer.setLinearVelocityY (0);
    }
    #3
    08/18/2007 (1:10 am)
    Thanks much,

    Man those are hard to notice