C++ Integration
by Andrey-Gr · in Torque Game Builder · 12/01/2011 (11:24 pm) · 3 replies
Hello!
I'm beginner with TGB, could someone please explain how can I integrate my C++ code with TGB, I already read couple of tutorials "Fill Battle" for example but still this is not clear for me.
In my C++ code I have some basic game entities, FSM and text output :),
question is how can I control scene objects through my C++ code?
The first thing I want to do is simply output text from my FSM into the "Text Object" in my scene file, please point me, how can I do such thing?
I'm beginner with TGB, could someone please explain how can I integrate my C++ code with TGB, I already read couple of tutorials "Fill Battle" for example but still this is not clear for me.
In my C++ code I have some basic game entities, FSM and text output :),
question is how can I control scene objects through my C++ code?
The first thing I want to do is simply output text from my FSM into the "Text Object" in my scene file, please point me, how can I do such thing?
#2
Just make sure that you've set the name of your text object to "FSMTextObject" in the TGB editor.
12/05/2011 (11:10 am)
I went and double-checked and that's definitely it. So, if you want your C++ FSM to write text into a text object, uset2dTextObject *ctrl = dynamic_cast<t2dTextObject *>(Sim::findObject("FSMTextObject"));
if( ctrl )
ctrl->setText( "Your text goes here..." );Just make sure that you've set the name of your text object to "FSMTextObject" in the TGB editor.
Associate William Lee Sims
Machine Code Games
You can then cast that to a t2dTextObject (or whatever class it is). Then you can use the standard C++ functions (like .setText) to set the text in the C++ code.