Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon


4. April 2016

 

Torque2D, an open source (MIT) 2D game engine build on top of Torque 3D technology, just released version 3.3.  This release adds two major new features, positional audio and TextSprite.

From the release notes:

Positional Audiot2d

Simon already put together an in-depth blog post on the virtues of positional audio. You can find it here. Let me give you the highlights. First, one scene can act as a listener. Then any object in that scene can call %object.playSound("beepAssetID") to play that sound. Those sounds can take an optional second parameter which is an AudioDescription. The AudioDescription can specify if the sound should loop along with a few handy other features. These were previously available in older versions of the engine so I image many of you will get the hang of them quickly.
Of course the whole point of all this is to hear the sound in the position it is on the screen. The best part is that the Doppler Effect happens. So you can make things quiz past your characters without any extra work. Again see Simon's blog for more details.

TextSprite

My contribution was the TextSprite. The previous bitmap font sprite, called the ImageFont, has been removed, but I tried to keep the TextSprite as similar as possible to keep updating your projects simple. The TextSprite is far more powerful than the ImageFont and I don't think you'll want to look back once you start using it.

FontAsset

It all starts with a FontAsset which is a new asset that basically takes a Bitmap Font File as its main parameter. This is the file generated directly by AngelCode's Bitmap Font Generator. In fact, the ToyAssets module includes a configuration file with a few example fonts to make it super easy to use. Basically to add a new font you just save the file using the Font Generator and then make a FontAsset taml file with the asset name and a reference to a font file. And just like that, you've got a new font that you can use in your game. The documentation is in the Github T2D Wiki if you want to learn more.

Features

The TextSprite is loaded with cool features so I'll type fast. First, you give your TextSprite a valid FontAsset. Unlike the ImageFont, you can set the size of the TextSprite and think of its bounding box as a box to type in. Inside the box you can align the text to the left, right, center, and justify. You can also vertically align the text to the top, middle, or bottom. When it hits the edges of the box you can set the overflow options. Horizontally, this includes the ability to word-wrap the text, which was a major missing feature of the ImageFont. But you can also shrink the text to fit, clip the text, or just let it overflow the box. Vertically you have similar options sans the wrap.
The font has a font size that applies to every character, but you can further customize the size by scaling the font in the x or y direction. On the font level you can also set the kerning (that's font lingo for space between characters). And finally, since this is a sprite you can set the blend color, rotation, and do things like collisions. You can even grow the sprite which will dynamically change the word-wrapping over time. We could stop here and you'd be happy, but it gets better.

Super Cool Features

You might want to sit down for this. You can change the blend color, scale, and position of individual characters. That means that you can have all white text and put that critical word in blue. You can make the letters shake for a cold character. You could have the text appear one letter at a time as a dialog box as seen in nearly every game. All this and more is now possible with the TextSprite. A new TextSprite Toy has been added to the Sandbox that demonstrates some of these tricks. Take a look at it and then give it a try.

GameDev News ,

blog comments powered by Disqus

Month List

Popular Comments