Game Development Community

Animated sprites in GUIBitmap?

by Jonathan Skinner · in Torque X 2D · 06/25/2007 (9:06 am) · 1 replies

GUIBitmap appears to accept only static images. I'm trying to implement an animated sprite, such as a health bottle, into a HUD (using the whole GUICanvas, GUIBitmap, GUIText etc.)

As I say, I can't find a way to get GUIBitmap to use T2DAnimatedSprite.PlayAnimation

I don't particularly want to implement the fallback solution, a really hacky "get each animation frame, destroy the GUIBitmap, create a new one with the next animation frame" through ProcessTick or other function. That would totally suck as well as be counter-intuitive.

Any ideas?

#1
06/26/2007 (12:21 am)
The way I implemented HUD-elements was to use T2DSceneObjects and not the GUIControls. I created a component that updates them in UpdateAnimation. So, for every frame you need to update the SceneObject positions based on the Camera position to make sure they're at the right screen position. It's not a perfect solution, but manageable. In theory, you could just mount your object to the camera, but I couldn't get it to work in beta (haven't tried it again in the final).

In addition, if you have a SplitScreen solution, you need to set the T2DSceneObject.ObjectType and GUISceneView.NoRenderMask so that they don't get rendered in everyones screen. For example with 2 players:

Player1HudObject.ObjectType = TorqueObjectDatabase.Instance.GetObjectType("Player1HUD");
Player1SceneView.NoRenderMask = TorqueObjectDatabase.Instance.GetObjectType("Player2HUD");

Matias