//
by Ryan Clifton · in Torque Game Builder · 12/28/2005 (7:19 pm) · 4 replies
//
#2
12/28/2005 (10:57 pm)
//
#3
There are two types of variables, local and global. Local ones only exist within each function but global ones exist, well, globally. :)
Local variables use the prefix "%" whereas global ones use the prefix "$". Here are a few examples:
You are not restricted to using local/global variables. There are ones that can be dynamically assign to objects. Let's say you have a player static-sprite called "$playerObject", you can do...
You can either put these commands directly into the ActionMap command (not recommended) or just call a function that does this; something like "increaseScore()"...
Hope this helps,
- Melv.
12/29/2005 (7:48 am)
The tutorial goes over the basics of how to setup keyboard commands using the "ActionMap" (Page#7) so I won't go over that again.There are two types of variables, local and global. Local ones only exist within each function but global ones exist, well, globally. :)
Local variables use the prefix "%" whereas global ones use the prefix "$". Here are a few examples:
%localVar1 %localVar2 $globalVar1 $globalVar2All the standard operators you'd expect are available to you so you can assign a value to a variable (or a string) using...
%localVar1 = 100; %localVar2 = "Hello!"; $globalVar1 = 200; $globalVar2 = "Hello World!"You can also add/subtract with...
%localVar1 = %localVar1 + 10; $globalVar1 = $globalVar1 - 20;... or the shortcuts ...
%localVar1 += 10; $globalVar1 -= 20;
You are not restricted to using local/global variables. There are ones that can be dynamically assign to objects. Let's say you have a player static-sprite called "$playerObject", you can do...
$playerObject.score = 1000; $playerObject.name = "Ryan";... and even change them as normal...
$playerObject.score += 20; $playerObject.name = "Ryan Clifton";
You can either put these commands directly into the ActionMap command (not recommended) or just call a function that does this; something like "increaseScore()"...
function increaseScore()
{
$playerScore += 20;
}Hope this helps,
- Melv.
#4
12/29/2005 (9:58 am)
//
Torque Owner Jesse Hall
The question you pose in this thread can be easily answered by going over the basic tutorial included in the Doc folder in your t2d install.
best of luck!
- Jesse