Game Development Community

Animated Text Strategies

by Mark Mesich · in Torque Game Builder · 03/28/2006 (8:17 am) · 13 replies

Hey Guys,

In my game I would like to have text move around the screen and behave kinda like sprites. Ultimately it would be nice if it had the appearance of being on a particular graphic. Which leads me to my questions...

Is it possible to dynamically add text to a sprite? Do I need to do something like attach individual characters using separate frames or is there an easier way?

Can the gui controls be used instead? Seems to me that they are more restrictive given the different co-ordinate systems etc. Seems also that keeping a sprite and a gui control in synch would be painful.

Any better ideas?

Thanks a lot!
Mark.

#1
03/28/2006 (8:21 am)
This should let you do what you want. Its a sceneobject that displays text so it can do everything a sceneobject can do: www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7396
#2
03/28/2006 (8:17 pm)
Hey Owen,

Thanks for the tip! While checking into this (I was wondering whether the class had been rolled into the T2D build) I came across the following post www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=9760 which seems to suggest that the class doesn't play nicely in a recent T2D build. Are you aware of any issues?

Also, the installation instructions talk about a required modification to a file called fxSceneWindow2D.h. I dont seem to have this in my T2D installation and so am wondering how I would use this in the first place. Do you know where I am going off the rails?

Thanks,
Mark.
#3
03/28/2006 (8:18 pm)
Everything with FX in front changed to t2d in front with 1.1
#4
03/28/2006 (10:19 pm)
Thanks guys this was very helpful!

I managed to make the necessary changes and got things to work. Although there are some shortcomings (like the text does not rotate etc) I think this will be suit my needs just fine!

I submitted an update to the original resource with code and script updates. Hopefully I will be able to save someone else a little time.

Thanks again for your help!
Mark.
#5
03/29/2006 (1:51 pm)
Hey mark, can you post that in a zip somewhere so I can download it in the meantime?
#6
03/29/2006 (6:41 pm)
Hey WDDG,

Would love to but am not sure how to get it to you. The resource that I posted with the zip has not been approved yet. When it is I will be sure to post a link. In the meantime if there is another way to get it to you then please let me know.

Thanks,
Mark.
#7
03/30/2006 (12:52 pm)
Well you could email the .cc/.h files at, if that's fine with you.
If the turnaround on the resource update is usually pretty quick, i'll just wait it out.

mario@wddg.com
#8
03/30/2006 (4:54 pm)
Sent! Be sure to let me know if you have trouble.
#9
03/30/2006 (6:59 pm)
Sent! Be sure to let me know if you have trouble.
#10
03/31/2006 (8:54 am)
Well you could email the .cc/.h files at, if that's fine with you.
If the turnaround on the resource update is usually pretty quick, i'll just wait it out.

mario@wddg.com
#11
04/09/2006 (4:02 am)
Hey Mark, could you send me a copy?

daveandangietaylor@yahoo.com, if you're willing. Thanks heaps in advance. :)
#12
04/09/2006 (6:22 am)
You might want to have a look at this too...

www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=8484

-Tim
#13
04/09/2006 (12:00 pm)
Hi Tim. Thanks for that. I couldn't find the two ID_UNUSED_0XX entries referred to here:

Quote:Somewhere after line 53 in t2dBaseDatablock.h,
replace two ID_UNUSED_0XX entries with:
"ID_t2dImageFontDatablock"
"ID_t2dImageFontStringDatablock"

//-----------------------------------------------------------------------------
// Torque Game Builder
// Copyright (C) GarageGames.com, Inc.
//
// Base Datablock Object.
//-----------------------------------------------------------------------------

#ifndef _T2DBASEDATABLOCK_H_
#define _T2DBASEDATABLOCK_H_

#ifndef _SIMBASE_H_
#include "console/simBase.h"
#endif


///-----------------------------------------------------------------------------
/// Base Datablock 2D.
///
/// This serves as the root for all T2D datablocks.  All T2D datablocks should
/// inherit from this and use the validity checking provided.
//-----------------------------------------------------------------------------
class t2dBaseDatablock : public SimDataBlock
{
private:
    typedef SimDataBlock Parent;

    /// Validity.
    bool    mValid;

protected:
   // This holds the fields that were actually specified in the datablock. It is updated
   // by onStaticModified. This list is maintained so that only properties of a scene object
   // whose corresponding datablock entry has been specified will be changed.
   Vector<StringTableEntry> mSpecifiedFields;

public:
    /// Members.
    t2dBaseDatablock();
    virtual ~t2dBaseDatablock() {};
    virtual bool onAdd();
    virtual void onRemove();

    /// Validity Check.
    bool getIsValid(void) const { return mValid; };
    void setIsValid(bool status) { mValid = status; };

    // Retrieve Datablock Set.
    static SimSet* get2DDatablockSet();

    /// Register Datablock type with Console
    virtual void onStaticModified(const char* slotName);
    bool isSpecified(const char* variableName);


    /// Declare Console Object.
    DECLARE_CONOBJECT(t2dBaseDatablock);
};
DECLARE_CONSOLETYPE(t2dBaseDatablock)


///-----------------------------------------------------------------------------
/// Check FX Datablock.
///
/// Use this when you've got a datablock and you want to ensure that it's
///-----------------------------------------------------------------------------
template<class T> bool t2dCheckDatablock( T* pDatablock )
{
    return ( pDatablock != NULL && pDatablock->getIsValid() );
}

// Adds compatibility when using SimObjectPtr<> Template.
template<class T> bool t2dCheckDatablock( T pDatablock )
{
    return ( pDatablock != NULL && pDatablock->getIsValid() );
}


#endif // _T2DBASEDATABLOCK_H_

So where do I put "ID_t2dImageFontDatablock" and "ID_t2dImageFontStringDatablock"?