hog Posted November 25, 2003 Posted November 25, 2003 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 Quote My website
*Experts* mutant Posted November 25, 2003 *Experts* Posted November 25, 2003 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. Quote
Administrators PlausiblyDamp Posted November 25, 2003 Administrators Posted November 25, 2003 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
hog Posted November 25, 2003 Author Posted November 25, 2003 Very interesting views, thnx you have given me something to think about:) Quote My website
hog Posted November 25, 2003 Author Posted November 25, 2003 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:) Quote My website
*Experts* mutant Posted November 25, 2003 *Experts* Posted November 25, 2003 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. Quote
hog Posted November 25, 2003 Author Posted November 25, 2003 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 Quote My website
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.