Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Just talking out loud here and hope someone can assist?

 

Say I have a sprite class which has a new method which takes the image path to load it into its internal bmpImage property and a draw method which uses this property to draw on screen.

 

Now this would work fine for a sprite with a single image. But what of sprites with multiple images?

 

Would I need to redefine my sprite class to hold and array of bitmaps or should I leave it as is and the answer is to have an array of sprites?

 

Try to get my head around this to produce an animated spaceship rotating 360 degress.

 

Thnx

My website
  • *Experts*
Posted
What is usually done in those cases is having one bitmap which contains all the frames of the image. Then based on what you need, you draw a given part of that image.
  • Administrators
Posted

I'd go for an array of bitmaps - that way the sprite class itself can handle things like timings, sequences etc internally without the client application having to understand the internal workings of the sprite.

 

The sprite can then be given methods like RotateClockwise, RotateAnticlockwise, DisplayExplosion etc.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
Mmm your comments have jogged my memory. I think I took the approach of having all sprites stored in a single .jpg file and then loading them into an array of images in the sprite object when I programmed my space invader game. But that was in 1995 and not only have I since lost the code which was written in C++ which I don't know anymore I have also been drunk too many times to remember:)
My website
  • *Experts*
Posted
If you plan on doing it that way, do not divide the image into other image objects then, that is what I think you are doing from reading your post. Instead, create an array of Rectangle strucutres which specify the part of image that is the given frame.
Posted

OK Thanks. Is there an advantage then doing it that way rather than assigning each frame to its own bitmap object. Is memory saving the issue here?

 

Ta

My website

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...