Game Development Community

text with sprite

by Jason Fermor · in Torque 2D Beginner · 05/19/2014 (11:53 am) · 3 replies

Hi, i have made a simple game but i am looking for a way to add text above a sprite and link them together so they move together.

for example i have a sprite of a car
i want above the sprite the text saying "Player 1"
and for the text to move with the sprite

how do i do this? thanks, Jason

About the author

Recent Threads

  • Path finding

  • #1
    05/19/2014 (11:53 pm)
    You could use an ImageFont object (look at the example in Sandbox's ImageFont Toy for details) and create a joint to hold both together.

    Another, more complicated way to do it would be to create a GuiTextCtrl and an empty Sprite. You would then call

    MySprite.attachGui(myGuiTextCtrl, MainSceneWindow,true);

    so that the Gui would adopt the size of MySprite as well as its position.

    You would then simply link MySprite with your Car object with a joint.
    #2
    05/20/2014 (7:46 am)
    The less cool way would be to incorporate the text in the sprite. It's less cool because you don't use physics joints and because it potentially increases your artwork resources exponentially - each player must have a "copy" of each player sprite option (if you can choose the color of your sprite, for instance).

    It's the bad way, but it's an option....
    #3
    05/21/2014 (8:50 am)
    Thank you for your help. I have made it work :) thanks. Jason.