Game Development Community

Creating sprites with Datablocks

by Kurtis Seebaldt · in Torque Game Builder · 03/12/2005 (4:57 pm) · 4 replies

So, I've been trying to create a sprite based on a datablock. For example:

datablock fxStaticSpriteDatablock2D(Sprite1) {
    imageMap = sprite1ImageMap;
}

Now, normally in Torque you would go about creating something with this datablock like this:

%player = new Player() {
    dataBlock = SomeGuy;
}

I tried this in T2D and it didn't work:

%player = new fxStaticSprite2D() {
    scenegraph = playSceneGraph2D;
    dataBlock = Sprite1;
}

After digging around in the source I found out how to do it:

%player = new fxStaticSprite2D() {
    scenegraph = playSceneGraph2D;
    config = Sprite1;
}

Just a note to anyone else that runs into this problem.

#1
03/13/2005 (2:06 am)
Thanks!

Yeah, lots of documentation needed. Thanks for helping out.

That "config" field would be very useful for more complex applications.

- Melv.
#2
03/13/2005 (7:02 am)
Excuse my ignorance, but how come its config and not datablock? Is this just semantics or is there more to it?
#3
03/13/2005 (7:28 am)
It's just the name of the field really.

If this is a problem, you can just change it in "fxSceneObject2D.cc" (approx line 2947).

addField("config", TypeSimObjectPtr, Offset(mConfigDataBlock, fxSceneObject2D));

- Melv.
#4
07/04/2005 (11:48 pm)
I know this an older thread, but this tripped me up also. The TGE docs say to use "datablock =", so hence the confusion.