Problems with tutorial (newb)
by Youssef Sleiman · in Technical Issues · 10/11/2007 (2:39 pm) · 1 replies
So, in a bid to try and show a company my game design, they said they needed a working version. So I turn to Torque (pun) Game Builder, the 2D.
The problem I've immediately run against is setting behavior in the Fish game ... The tutorial's own steps end in an immovable fish-player. There is something missing to the tutorial that I'm not sure how to discover.
I've no programming know-how, so any basic help for people observant enough to see if they've done something extra to implement behaviors to objects, let me know.
Here's the skinny... I've written the .cs file as the tutorial suggests. I've got the behavior integrated into the level builder (as in I can bind keys.) It's clearly associated to the animated fish object. When I run the game, though, no keys -- not even the keys I've bound to behaviors -- operate the fish. This is a backwards step in my attempt to develop this game myself. (Everyone I've talked to has said, ah well... looks hard, I can't help ya.)
So. Behaviors. Tricky to work.
-Youssef Sleiman
(PS: E-mail me, too.)
The problem I've immediately run against is setting behavior in the Fish game ... The tutorial's own steps end in an immovable fish-player. There is something missing to the tutorial that I'm not sure how to discover.
I've no programming know-how, so any basic help for people observant enough to see if they've done something extra to implement behaviors to objects, let me know.
Here's the skinny... I've written the .cs file as the tutorial suggests. I've got the behavior integrated into the level builder (as in I can bind keys.) It's clearly associated to the animated fish object. When I run the game, though, no keys -- not even the keys I've bound to behaviors -- operate the fish. This is a backwards step in my attempt to develop this game myself. (Everyone I've talked to has said, ah well... looks hard, I can't help ya.)
So. Behaviors. Tricky to work.
-Youssef Sleiman
(PS: E-mail me, too.)
Associate Phillip O'Shea
Violent Tulip
Lets say your behavior is called "FishBehavior", then you need a function that will actually use the information that you have set in your editor and apply it to the object in question.
function FishBehavior::onAddToScene(%this, %scenegraph) { if (!isObject(moveMap)) return; moveMap.bindCmd(<device>, <action>, <makeCmd>, <breakCMD>); }The parameters you will be using will no doubt be in your behavior (which in this case is the %this variable).
Lets say, you want the fish to move left with the button keyboard left. Your keybind field should store the left keyboard key in the form:
This points the first word to the device it is using, and the second word to the key you want to use.
Therefore, you would want your bindCmd to look something like:
... moveMap.bindCmd(getWord(%this.LeftKey, 0), getWord(%this.LeftKey, 1), %this @ ".moveLeft();", %this @ ".stopMoveLeft();"); ...Then your moveLeft and stopMoveLeft functions should look like:
function FishBehavior::moveLeft(%this) { //MoveMe } function FishBehavior::stopMoveLeft(%this) { //StopMovingMe }Just remember that whenever you try to apply changes to the object, you must apply them to %this.owner, because %this points to the behavior object rather than the owner.
Hope this helps.
By the way, you should post in the TGB forums rather than this one, you may get more people reading it.