RedMonkeyRon |
Posted - Aug 10 2005 : 01:35:08 AM I have a working Pokemon-like 2D game, but it runs like a slug. I based it on this tutorial: http://dotnetforums.net/showthread.php?t=87878, but the tutorial didn't go into how to actually alter the vertices of each sprite. Therefore, to simulate movement, I'm disposing and re-creating 150 sprites for each time the little man moves. Ugh.
I suspect that can just change topleft.x and topleft.y of each vertex (each sprite contains 4) and then re-render the scene, therefore simulating movement. However, I don't know how to edit the vertices in an existing sprite.
The sprite class clsSprite contains: Private dxDevice As Device Public SpriteImage As Texture Public vBuffer As VertexBuffer
Question: How do I reference something life clsSprite.vBuffer.Vertex(x).TopLeftX and edit them? If I can get the performance to a less embarrassing point, I promise I'll put the base code out here. Thanks!!! |
Eric Coleman |
Posted - Aug 10 2005 : 12:07:42 PM You don't alter the vertices of the sprite after you create it.
The trick is to use a matrix for each sprite. A matrix allows you to specify things like position (commonly refered to as "translation"), rotation, shearing (like a parrallelogram), and stretching/shrinking.
Look at the directx 9 section here, http://directx4vb.vbgamer.com/ for more information. Of course, you should also consider downloading the Directx 9 SDK. I know it doesn't have any VB.NET examples, but it's still a good source of information. |
|
|