Spritemovement and VertexBuffers

Loffen

Regular
Joined
Mar 21, 2004
Messages
51
Location
Akershus, Norway
Well, The only way i figured to move a sprite (stored in a vertexbuffer), is to dispose the buffer and create a new one with new vertices... This sound really inefficent, but i've seen lots'a things with direct3d that didnt sound efficent...

Any suggestions??

EDIT: it did effect my framerate while moving one object. I lost about 4-8 of 150 FPS... This is no real problem, but if it should move 100 objects??

--Loffen
 
Last edited:
Nono man :).
This is not how you move the sprite. There is something called World Transformations. In order to move the sprite, you must move the WORLD.

For example, if the sprite is at 0,0,0.

dxDevice.Transform.World = Matrix.transformation(2,0,0) would move the sprite over 2 units to the rihgt.

dxDevice.Transform.World = Matrix.Multiply(dxDevice.Transform.World, Matrix.Translation(2,0,0)) would move the sprite 2 units to the right - each time the line gets executed. (If you put it in the render loop, it will move 2 units each frame)

The first line dxDevice.Transform.World = Matrix.transformation(2,0,0) will only move the world to that point. No matter how many times you execute it, it will only move it to the right once... err its confusing - but experimenting with the code should help you understand.

"In order to move the sprite, you must move the WORLD." - heh,
I'm 100% sure the next question you will ask is: "If I have to move the WORLD to move 1 character, how do I move 2 characters if they wish to go in opposite directions?"
-There's a post on the forum which i answered, just search for it :).

-The Pentium Guy
 
Back
Top