Game Development Community

StaticSpriteDatablocks?

by Ken Pajala · in Torque Game Builder · 07/13/2006 (6:54 pm) · 4 replies

In the platformer tutorial tdn.garagegames.com/wiki/Torque_2D/GenreTutorials/PlatformerLevels it mentions the following:
Quote: Each type of T2D object (StaticSprite, AnimatedSprite, etc) has an associated datablock (StaticSpriteDatablock, AnimatedSpriteDatablock, etc).

Do these exist anymore? Do we just use t2dSceneObjectDatablock for any of our datablock needs for things derived from Scene Objects?

#1
07/14/2006 (2:20 am)
Yes, you can use t2dSceneObjectDatablocks exactly the same way you used the other datablocks before.
E.g.:
datablock t2dSceneObjectDatablock(exampleDatablock)
{
    class = "someClass";
    size = "16 16";

    imageMap = "someImageMapDatablock";
};


new t2dStaticSprite()
{
    sceneGraph = $YourSceneGraph;
    config = "exampleDatablock";
};

The imageMap field in the config datablock gets transferred just like any other fields.
#2
07/14/2006 (5:20 am)
It's also worth mentioning that any given datablock can only be used for one specific object class. For example, if you define a t2dSceneObjectDatablock (which you might assume would be available to any scene object class) and then assign that datablock to a t2dStaticSprite even once, that specific datablock cannot be used for anything other than t2dStaticSprite's and will give you a console error if you try to later apply it to, for example, a t2dAnimatedSprite. This might seem limiting, but you can actually set a datablock to inherit from another datablock, so it really just comes down to organization.

Edit: THIS IS WRONG - READ MY LATER POST!
#3
07/14/2006 (7:11 am)
Yeah, really? I didn't know that. I think it should be possible to have the same datablock for a static and an animated sprite - unless you don't use the class or superclass field (which will corrupt namespace linking).
I have no tried that though...
#4
07/14/2006 (9:31 pm)
My mistake, that applies only if you set a class in your datablock.

Edit: (or superclass)