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 );
}
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 );
}
#2
function fishPlayerUpStop() {
$FishPlayer.setLinearVelocityY {0);
}
should be
function fishPlayerUpStop() {
$FishPlayer.setLinearVelocityY (0);
}
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);
}
Torque Owner Freeze
WKA Games
// 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