animated Texture/HUD/GUI
animated Texture/HUD/GUI
hi,
i am making a game and need the health bar to start flashin red when it gets below a certain level, i know the code to change the texture and to detect the level, but have no idea how to animate the texture, or is it just a case of changing the texture every other second or is there a better method?
any help would be much appreciated
i am making a game and need the health bar to start flashin red when it gets below a certain level, i know the code to change the texture and to detect the level, but have no idea how to animate the texture, or is it just a case of changing the texture every other second or is there a better method?
any help would be much appreciated
The idea of war is not to die for your country, but to make the other bastard die for his!
I'm guessing your HUD is 2d, so what I would do here is sprite animation.
That would be explained in this Irrlicht tutorial:
http://irrlicht.sourceforge.net/tut006.html
The time code in the draw loop controls the texture swap.
Anyone else have another method?
That would be explained in this Irrlicht tutorial:
http://irrlicht.sourceforge.net/tut006.html
The time code in the draw loop controls the texture swap.
Anyone else have another method?
-< Dante >
< Industry Senior QA Tester>
< IT Project Manager>
< Independent Programmer>-
< Industry Senior QA Tester>
< IT Project Manager>
< Independent Programmer>-
I'd probably just switch the textures of the gui element personally, makes for less code and is a bit simpler, and shouldn't cost any more in performance.
If you preload the textures then you won't have any slowdown while the texture loads on the first time you set the textures.
So you'd do something like this:
During loading:
driver->getTexture("bar texture 1.jpg");
driver->getTexture("bar texture 2.jpg");
That will load both the textures into the texture cache so when you set the texture later, using a call to driver->getTexture(".."); it won't have to load it again.
Or you could keep a pointer to the textures to save a call to getTexture which would have to check through the whole texture cache.
In raw opengl i'd just have a grayscale texture for the bar and then change the colour it's rendered in as required, not sure if there's a way to do that in irrlicht though, do the draw2D functions allow you to specify a colour to colour the texture in?
If you preload the textures then you won't have any slowdown while the texture loads on the first time you set the textures.
So you'd do something like this:
During loading:
driver->getTexture("bar texture 1.jpg");
driver->getTexture("bar texture 2.jpg");
That will load both the textures into the texture cache so when you set the texture later, using a call to driver->getTexture(".."); it won't have to load it again.
Or you could keep a pointer to the textures to save a call to getTexture which would have to check through the whole texture cache.
In raw opengl i'd just have a grayscale texture for the bar and then change the colour it's rendered in as required, not sure if there's a way to do that in irrlicht though, do the draw2D functions allow you to specify a colour to colour the texture in?
That's exactly my idea for him,JP wrote:In raw opengl i'd just have a grayscale texture for the bar and then change the colour it's rendered in as required, not sure if there's a way to do that in irrlicht though, do the draw2D functions allow you to specify a colour to colour the texture in?
API wrote:virtual void irr::video::IVideoDriver::draw2DImage ( const video::ITexture * texture,
const core::position2d< s32 > & destPos,
const core::rect< s32 > & sourceRect,
const core::rect< s32 > * clipRect = 0,
SColor color = SColor(255, 255, 255, 255),
bool useAlphaChannelOfTexture = false
) [pure virtual]
Draws a 2d image using a color.
(if color is other than Color(255,255,255,255)) and the alpha channel of the texture if wanted.
Parameters:
texture,: Texture to be drawn.
destPos,: Upper left 2d destination position where the image will be drawn.
sourceRect,: Source rectangle in the image.
clipRect,: Pointer to rectangle on the screen where the image is clipped to. This pointer can be NULL. Then the image is not clipped.
color,: Color with which the image is colored. If the color equals Color(255,255,255,255), the color is ignored. Note that the alpha component is used: If alpha is other than 255, the image will be transparent.
useAlphaChannelOfTexture,: If true, the alpha channel of the texture is used to draw the image.
i posted a code snippet here
http://irrlicht.sourceforge.net/phpBB2/ ... highlight=
using color interpolation, take a look
maybe you dont need to use texture for the bars, just draw a rectangle and play with the colors inside it, you can set a diferent color for each vertex for example, and to make it flash just change the color each X loops in the main loop or something like this
http://irrlicht.sourceforge.net/phpBB2/ ... highlight=
using color interpolation, take a look
maybe you dont need to use texture for the bars, just draw a rectangle and play with the colors inside it, you can set a diferent color for each vertex for example, and to make it flash just change the color each X loops in the main loop or something like this
no hard no fun - eMgz
cheers for all the sugestions, ive used the changing images bit because we have already got tectures for the health bar so can just go changing it to jus normal solid colours, looks pretty cool though.
thanks again
thanks again
The idea of war is not to die for your country, but to make the other bastard die for his!
-
- Posts: 914
- Joined: Fri Aug 03, 2007 12:43 pm
- Location: South Africa
- Contact:
If you still looking for animated textures, i can help you a lot with the showing and managing of it, even with mouseover and click events...
Take a look here, and if you want to test it for me i can help you out,
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=26343
Take a look here, and if you want to test it for me i can help you out,
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=26343
-
- Posts: 914
- Joined: Fri Aug 03, 2007 12:43 pm
- Location: South Africa
- Contact:
-
- Posts: 914
- Joined: Fri Aug 03, 2007 12:43 pm
- Location: South Africa
- Contact: