A few questions about ID3DXSprite

Started by
3 comments, last by MadMechwarrior 20 years, 3 months ago
Well im a rather newbie programmer when it comes to DX, I know the basics of it pretty well and how the VBs and IBs work but have yet to settled down and write an actual game/application. Im trying to write a simple side scroller game, started 3 days ago taking it really slowly. Im still stuck in the backend... A I have a few questions on ID3DXSprite, which is what im using for now until I find the performance is too crappy. Anyways if you guys could anwser this I would appreciate it alot. 1. One thing i''ve noticed is when I run my little test app in windowed mode the proportions of the image change depending on the aspect ratio of the window. Like it I strech the window out the image streches. Im guessing this is because im working with floating point DX x and y coords and not actual pixels but I was wondering if there was any way to fix it so a sprite would always be the same size no matter what size the window is? 2. I know to draw a sprite you have to first run the Begin function, then draw a bunch of sprites then do End and they get displayed. Well I was writing my little sprite class which renders itself (MySprite->Render() in between begin and end) All this does is call the draw function. I dont know if this is the way to go yet, if anybody can help me there. But when I can render in between begin and end it doesnt work but if I call draw in my main loop function and I get the texture from the sprite class (would be something like Sprite->Draw(MySprite->m_pTexture, NULL, NULL, NULL); ) it works. This still puzzles me... 3. How do I go about rotating the sprites, is it matrices? Im aware im using the helper class which kinda sucks right now (im a more hands on person so I like to do this stuff myself but right now im just trying to get a small thing working and worry about optimizing later). Thanks ahead, I havent posted here in a while but I finally decided to try a small project to practice my C++ and DX before the HL2 SDK came out (which is where im going next) so I came back here :D. "Me no sound like yoda... Do I" "Its not easy being green"
"Me no sound like yoda... Do I""Its not easy being green"
Advertisement
1) I''m not really sure what you are talking about with this, because when I used the ID3DXSprite interface, it stays the same dimensions, no matter what the size of the window (this would originate from the fact that it''s drawing in coordinate space, not screen space). Actually, check your Begin() method. I remember you could set a flag there to draw in coordinate or screen space - if you want it to size with the window, use screen, otherwise, use coordinate.

2) What you should do is pass your sprite object a pointer to the sprite object ( like MySprite->Render( LPD3DXSPRITE spriteInterface). Then use the draw method of that interface in your Render() function. Maybe you''re already doing that, though.

3) Yep, use matrices for all transformations
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
You should call mydevice->reset() whenever you detect the window has been resized, when running in windowed mode.
Make sure you update BackBufferWidth and BackBufferHeight with the respective sizes of your window before calling Reset, however.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
circlesoft: for #2 I setup the device and the sprite interface as static so its always the same interface. Dont see why it doesnt work. Has anybody else tried to make a sprite engine and did it differently?
"Me no sound like yoda... Do I""Its not easy being green"

This topic is closed to new replies.

Advertisement