Jump to content
  • Advertisement
Sign in to follow this  
BloodWarrior

Sprite performance in MIDP 2.0

This topic is 4139 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Heyas Just a quicky: Sprite in MIDP 2.0 is created from an image (with or without multiple frames). What I want to know is how the link to the image is maintained: Is the sprite keeping a reference to the image or creating a copy of the image for its own use? The main reason is: if I create 10 sprites based on the same image (10 enemy ships for example) are they all sharing the same images or are they each implementing their own? It would make quite a difference in performance as keeping one image in memory and 10 is quite a different thing. Does anyone know this?

Share this post


Link to post
Share on other sites
Advertisement
I don't think the spec defines that behaviour but I've never seen an implementation that makes copies, and I would be very surprised to see one.

shmoove

Share this post


Link to post
Share on other sites
Quote:
Original post by shmoove
I don't think the spec defines that behaviour but I've never seen an implementation that makes copies, and I would be very surprised to see one.

shmoove


hm... when the sprite is created from an image using a certain width and height to create multiple frames: Is it creating a set of images that it will use or simply setting reference points to copy itself from the original image when needed?

I guess that the best way to figure this one out is to create a sprite from a mutable image and then modify the image.
If the sprite changes with it then it was referencing it, if it doesnt then it has its own copy which means that multiple sprites of the same image is a waste of memory (holding lots of copies of the same image).

I think my reasoning is right... so i guess ill test it and let you guys know.
If anyone has a better reasoning (or the answer) please let me know.

Yours Truly
K

Share this post


Link to post
Share on other sites
Ok
I tested this at home

Created an Image, drew some crap into it then created two sprites from the image.
After a few seconds (in a paint loop) I drew a black square into the original image.
Both sprites displayed it.

So Sprites do hold a reference to the original image which cannot be destroyed or changed while the sprite is using it. This also results in a very good performance as multiple sprites sharing the same image do not waste memory with their own personal copies of the images.

It was just something bothering me since i wasnt certain.

Yours Truly
K

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!