Problem passing a t2dTileMap reference as a parameter.
by Joshua Jewell · in Torque Game Builder · 10/08/2007 (8:18 pm) · 3 replies
I have created my own subclass of t2dSceneObject. What I would like to do is pass a reference of a t2dTileMap in as a parameter so that it may be set as a member variable.
I am using a scripting name as a reference to the t2dTileMap. In the console method I wrote the following line to lookup the sim object.
This cast is failing and returning a null pointer. When I switch the cast to a I get a reference to an actual object.
My question is whether or not I have approached this problem correctly. Is there any special behavior of the t2dTileMap which may be preventing me from getting at its actual sim id?
I am using a scripting name as a reference to the t2dTileMap. In the console method I wrote the following line to lookup the sim object.
t2dTileMap* pTileMap = dynamic_cast<t2dTileMap*>( Sim::findObject( argv[2] ) );
This cast is failing and returning a null pointer. When I switch the cast to a
My question is whether or not I have approached this problem correctly. Is there any special behavior of the t2dTileMap which may be preventing me from getting at its actual sim id?
#2
Here are the steps that I performed:
1) Create a tileMap though the Game Builder.
2) assign a name of tiles in the Scripting tab.
3) assign a class of tileLayerClass in the Scripting tab.
4) in script call myObj.addRef( tiles.getId() );
Now I did a check and when I echo out tiles.getId() the sim id of 1502 is returned. This is the same id which argv[2] contains(in string format).
Is there any way I may not actually be referencing the t2dTileMap?
10/09/2007 (2:36 pm)
What has me confused is that I am passing it an object id which I expect to be a t2dTileMap.Here are the steps that I performed:
1) Create a tileMap though the Game Builder.
2) assign a name of tiles in the Scripting tab.
3) assign a class of tileLayerClass in the Scripting tab.
4) in script call myObj.addRef( tiles.getId() );
Now I did a check and when I echo out tiles.getId() the sim id of 1502 is returned. This is the same id which argv[2] contains(in string format).
Is there any way I may not actually be referencing the t2dTileMap?
#3
10/09/2007 (8:57 pm)
I figured out what was wrong. The Sim Object was a t2dTileLayer instead of the t2dTileMap which I expected.
Torque 3D Owner Stephen Zepp
The fail of the cast in this case is indicating that whatever argv[2] references (an object ID I assume), the pointer that is returned is to an object that does not have t2dTileMap in it's parentry.