Game Development Community

Major Builder

by rennie moffat · in Torque Game Builder · 07/26/2009 (7:06 pm) · 2 replies

Hi there, this is the code that I have developed for my player. It still crashes my system. Going on this, do you see any major errors I should correct?
Obviously, I have so many events, probably too many running off of the MouseDown event, but I do want this to happen, so should I group all player functions that run off of the click in one "group" and the one that must record/set world positions in another?

function onLevelLoaded (%this, %scenegraph)
{
if(!sceneWindow2D.getUseObjectMouseEvents())
   {
      sceneWindow2D.setUseObjectMouseEvents(true);
	  }
	   // set this object to accept mouse events
   %this.setUseMouseEvents(true);
   


$cube=%this.getCubePosition, set as Cube Position;
moveMap.bindCmd(mouse, "click";, "cubeMovement";, "cubeMoveX();", "cubeMoveStopX;", "cubeMove-X();", "cubeMoveStop-X;", "cubeMoveY();", "cubeMoveStopY;". "cubeMove-Y();", "cubeMoveStop-Y;",);
}


function recordMousePosition::onMouseDown
{
%this.mousePosition=setPosition; 
}


About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.


#1
07/26/2009 (10:21 pm)
Quote:Going on this, do you see any major errors I should correct?
TBH it's hard to find a line without major error.

Quote:
function someClass::onLevelLoaded (%this, %scenegraph)
{
if(!sceneWindow2D.getUseObjectMouseEvents())
{
sceneWindow2D.setUseObjectMouseEvents(true);
}
// set this object to accept mouse events
%this.setUseMouseEvents(true);



$cube=%this.getCubePosition(), set as Cube Position; << is this a comment?
moveMap.bindCmd(mouse, "click";, "cubeMovement";, "cubeMoveX();", "cubeMoveStopX;", "cubeMove-X();", "cubeMoveStop-X;", "cubeMoveY();", "cubeMoveStopY;". "cubeMove-Y();", "cubeMoveStop-Y;",);
}


function recordMousePosition::onMouseDown()
{
%this.mousePosition=someObject.setPosition();
}

Just some quick thoughts:
- bindCmd takes 4 parameters only, you try to use it with 11.
- Parantheses missing several times.
- A period instead of a comma (typo)?

IMO you should try coding more carefully and consider reading a book about Torque Script.
#2
07/27/2009 (9:19 am)
great, so really they are all very minor.

I do want to relate/have mouse dictate all moves by its click. tho i will move that click into a class with lots of if statements. thanks.PS. I am using 2D Game Building for Teens, it is proving to be quite useful.