Game Development Community

scripting question

by David Sinkler · in Torque X 2D · 04/16/2011 (3:54 pm) · 2 replies

i am using torque game builder.( I know...but i don't see the foums for tgb, sorry,)

my question as a noob, is:

when i'm going through the tutorials, i am told to right something like: function PlayerFish::onLevelLoaded..etc. well they explain what function is and class and etc but not the " :: " what is that and what does it mean?
also what is example moveMap.bindCmd what does the " . " mean? i hope you can help and I will have an "ohh" i get it now moment. thanks and sorry for posting on torque x 2d.

#1
04/16/2011 (6:12 pm)
@David - These are traditional programming operators. TorqueScript is very C like in its syntax. When you write something like:

PlayerFish::onLevelLoaded(..)

You are using the scope operator (::). The code inside of that function will be executed specifically to objects that use the PlayerFish class. The period operator (.) is an accessor. In your example, there is an object (moveMap) and a function (bindCmd). bindCmd is one of moveMap's methods. To call that function, you use the accessor.
#2
04/16/2011 (6:14 pm)
If you want an overview of TorqueScript, check out the iTorque 2D Documentation. Torque 2D and iTorque 2D are built on the same technology, so the documentation on scripting applies. Be sure to read the Overview and Syntax Guide docs.