Game Development Community

Sliding UV coords

by Lennart Steinke · in Torque Game Builder · 04/08/2005 (4:27 pm) · 1 replies

Hi!

I'd like to start with saying that this is not a feature request nor something very important for me. I've already a working solution for the problem described here, I just think that the working solution I have isn't very elegant :)

My goal is an animated score display that looks more or less like this:
www.spellcaster.de/t2d/counter.pngSo, when the score changes the digits will scroll until their new value is reached. I'm currently doing this by having a special fxSceneWindow2D to clip my hiscore widget. Each digit is a sprite that is offset in a way that the correct number is visible. When the score changes, I change the offset of the individual digits over time.

As I said, this works, but it kinda feels hacky to me.
I'd prefer to specify a quad for each digit and then simply slide the UV coords of the quad over the texture.

Is something like this already implemented in t2d and I was just to dense to find it? Or planned? Or has somebody already submitted a resource that does exactly what I just described? (I did my best to check for these possibilities - but experience taught me that I normally tend to miss the obviou stuff - even if it has a title like "Look at me, I'm exactly what you're looking for").

Or is there another way that is less hackish than my approach that I could implement in TScript right away?

-Lenny

#1
04/09/2005 (5:17 am)
A custom rendering object would be my first suggestion but if want to do this in TScript with each object being a seperate T2D object then there is a way to do it.

I'd suggest having your texture as a vertical strip of numbers 0-9.

Then, for each digit, I'd have an fxScroller2D to display the texture with vertical wrapping on. The texture would have to be a POT one and be in FULL mode.

This way, you can specify the offset for each digit by a single scalar value and the hardware would naturally wrap back to zero. You could use the auto-scrolling mechanism but it doesn't have a target scroll feature so you'd probably be best scheduling this. Wrap this up in a function for a string of values.

This would work but isn't the best way. Basing a new object on the static sprite wouldn't be difficult to do though and you could even add in some extra vertices/texture-coords and maybe the colours to distort the texture such that it looked like it was on a tumblers. You could also make the 'tumblers' static and just have the numbers blended on-top.

I'm not sure of any other method than described above to create this though.

- Melv.