Problem with miniPlatformTutorial
by Firas · in Torque Game Builder · 10/04/2006 (10:04 pm) · 0 replies
Hi guys
I'm implementing the miniPlatformer tutorial for the 3 time and I have the following problem:
first of all here is the code where the problem is:
function playerClass::onLevelLoaded(%this, %scenegraph)
{
$pGuy = %this;
moveMap.bindCmd(keyboard, "left", "playerLeft();", "playerLeftStop();");
moveMap.bindCmd(keyboard, "right", "playerRight();", "playerRightStop();");
moveMap.bindCmd(keyboard, "space", "playerJump();", "");
$pGuy.setCollisionMaxIterations(2);
}
function playerLeft()
{
$pGuy.moveLeft = true;
}
function playerLeftStop()
{
$pGuy.moveLeft = false;
}
function playerRight()
{
$pGuy.moveRight = true;
}
function playerRightStop()
{
$pGuy.moveRight = false;
}
function playerJump()
{
$pGuy.setLinearVelocityY(-225);
}
function playerClass::updateMovement(%this)
{
%yVelocity = $pGuy.getLinearVelocityY();
$pGuy.setLinearVelocityY(0);
if(%this.moveLeft)
{
%this.setLinearVelocityX(-60);
}
if(%this.moveRight)
{
%this.setLinearVelocityX(60);
}
if(!%this.moveLeft && !%this.moveRight)
{
%this.setLinearVelocityX(0);
}
%collision = $pGuy.castCollision(0.005);
if(%collision !$= "" )
{
$pGuy.setLinearVelocityX(0);
}
$pGuy.setLinearVelocityY(100);
%collision = $pGuy.castCollision(0.005);
$pGuy.setLinearVelocityY(%yVelocity );
if(%collision $= "")
{
$pGuy.setConstantForceY(100);
}
else
{
$pGuy.setConstantForceY(0);
}
}
function t2dSceneGraph::onUpdateScene()
{
if (isObject($pGuy))
$pGuy.updateMovement();
}
and the problem is the tutorial say that :
"Awesome, now the guy is hopping around and there's no stickiness. Time to get the screen to scroll with our plalyer."
but after this point the player still sticking and there is another problem it does not response when I press space on the keyboard (the character will not jump) and some time it will responce to the sapce key.
so how to solve this problem?
I'm implementing the miniPlatformer tutorial for the 3 time and I have the following problem:
first of all here is the code where the problem is:
function playerClass::onLevelLoaded(%this, %scenegraph)
{
$pGuy = %this;
moveMap.bindCmd(keyboard, "left", "playerLeft();", "playerLeftStop();");
moveMap.bindCmd(keyboard, "right", "playerRight();", "playerRightStop();");
moveMap.bindCmd(keyboard, "space", "playerJump();", "");
$pGuy.setCollisionMaxIterations(2);
}
function playerLeft()
{
$pGuy.moveLeft = true;
}
function playerLeftStop()
{
$pGuy.moveLeft = false;
}
function playerRight()
{
$pGuy.moveRight = true;
}
function playerRightStop()
{
$pGuy.moveRight = false;
}
function playerJump()
{
$pGuy.setLinearVelocityY(-225);
}
function playerClass::updateMovement(%this)
{
%yVelocity = $pGuy.getLinearVelocityY();
$pGuy.setLinearVelocityY(0);
if(%this.moveLeft)
{
%this.setLinearVelocityX(-60);
}
if(%this.moveRight)
{
%this.setLinearVelocityX(60);
}
if(!%this.moveLeft && !%this.moveRight)
{
%this.setLinearVelocityX(0);
}
%collision = $pGuy.castCollision(0.005);
if(%collision !$= "" )
{
$pGuy.setLinearVelocityX(0);
}
$pGuy.setLinearVelocityY(100);
%collision = $pGuy.castCollision(0.005);
$pGuy.setLinearVelocityY(%yVelocity );
if(%collision $= "")
{
$pGuy.setConstantForceY(100);
}
else
{
$pGuy.setConstantForceY(0);
}
}
function t2dSceneGraph::onUpdateScene()
{
if (isObject($pGuy))
$pGuy.updateMovement();
}
and the problem is the tutorial say that :
"Awesome, now the guy is hopping around and there's no stickiness. Time to get the screen to scroll with our plalyer."
but after this point the player still sticking and there is another problem it does not response when I press space on the keyboard (the character will not jump) and some time it will responce to the sapce key.
so how to solve this problem?
About the author