ID3DXSprite?

Started by
11 comments, last by Trip99 19 years, 8 months ago
Can anyone tell how to use sprites in Direct3D. Do you just make an instance of it and set it to use a bitmap for the texture. And how do you move it around the screen. I looked at the msdn documentation and I don't know how to implement these functions. I'm a real newbie to this so any comments would help. Thanks to everyone.
Advertisement
I read in the msdn documentation that the Draw method has a parameter for a texture. Do I have to call this in between the Begin and End Method? It has a position also that is a D3DXVECTOR3, do I update the vector every time I want it to move?
Moved to DirectX forum.
It's very easy. You do it like this:
// Load-time(1) Create the ID3DXSprite object, using the D3DXCreateSprite factory function.(2) Load your textures// Run-time(1) Call ID3DXSprite::Begin()(2) For each texture you want to render   (a) - Build and apply the translation matrix for a world-space translation       or       - Build the position vector for a screen-space translation   (b) Call ID3DXSprite::Draw()(3) Call ID3DXSprite::End()
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Don't think of D3DXSprite as an object or anything related to an instance of a single sprite. That's incorrect.

Instead, just view it as some extra code packaged into a single interface. You create a D3DXSprite to pull that code into memory, like loading a DLL; call through the ID3DXSprite interface to use the functions provided by that DLL; and then release the interface, like unloading a DLL. If you had a DLL providing behaviour for a specific enemy in your game, you wouldn't load it once per enemy...

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

How do i set the sprite to use the texture? For some reason I can't get the Draw() function to work.
Quote:Original post by circlesoft
It's very easy. You do it like this:
** Code Snippet **


Déjà Vu?

Andy: you have to load the texture into an textureobject, and then use a single instance of ID3DXSprite to draw all your textures.
Alright I got something to display on the screen. And what do you mean use a single instance, just use the draw() function for every texture I have?
Quote:Original post by Pipo DeClown
Quote:Original post by circlesoft
It's very easy. You do it like this:
** Code Snippet **


Déjà Vu?

[grin]
That's part of our (Dustin and me) proprietary, patent-pending technologies: Templated answers to extremely frequently asked questions, or TateFaq for short.

Quote:Original post by Coder
[grin]
That's part of our (Dustin and me) proprietary, patent-pending technologies: Templated answers to extremely frequently asked questions, or TateFaq for short.

Hehe.. I don't understand what you just said there (was that a joke?), but can I join in? Do you have more like those snippets?

This topic is closed to new replies.

Advertisement