Rendering only a certain portion of a background

Started by
1 comment, last by Moose6912 19 years, 8 months ago
I have a background png called background.png and a sprite that is rendered on top on it.Is there a way to render only the portion of the background.png which was affected by the sprite moving on top of it every cycle (thus saving time rendering) or i have to render the entire background.png at every cycle?
Advertisement
Look into Graphics.setClip(). I believe I already mentioned it to you in the other thread about image transparency.

However, note that the time taken to draw an Image direct to screen is pretty much constant (at least on the phones I've seen). So you probably won't gain much this way. It's also a very long time (typically 4 or 5 milliseconds), so you should instead be thinking more about ways to avoid drawing several Images to screen in your render loop. Consider using a mutable Image as a buffer, and only drawing to that when part of the image changes. If your image consists conceptually of more than one "layer" though (like 'background' versus 'sprite'), you may be better off handling each layer separately.
Quote:Original post by Zahlman
Look into Graphics.setClip(). I believe I already mentioned it to you in the other thread about image transparency.

However, note that the time taken to draw an Image direct to screen is pretty much constant (at least on the phones I've seen). So you probably won't gain much this way. It's also a very long time (typically 4 or 5 milliseconds), so you should instead be thinking more about ways to avoid drawing several Images to screen in your render loop. Consider using a mutable Image as a buffer, and only drawing to that when part of the image changes. If your image consists conceptually of more than one "layer" though (like 'background' versus 'sprite'), you may be better off handling each layer separately.


Thanx a lot,you did mention setClip().Since there won't be much difference between drawing an image as a background and drawing only the part that has been changed.I will just draw the background as a whole.

This topic is closed to new replies.

Advertisement