drawing an image to an offscreen image
HI guys, so far I've made a cool little java graphic that moves a ball around, bouncing it on walls (i was so happy when it worked).
I've researched how to use images in java gaming and also searched some forums, but no tutorials seem to do it the same way; the book i'm learning from is way too detailed and its examples often contain a million lines of unneccessary code.
public void update (Graphics g)
// initialize buffer
if (canvas == null)
canvas = createImage (this.getSize().width, this.getSize().height);
dbg = canvas.getGraphics ();
dbg.clearRect (0, 0, this.getSize().width, this.getSize().height);//draws a rectangle of background color over the whole image.
//if circle c hasn't been created, create it.
c.setBounds(this.getSize().width,this.getSize().he ight);//sets the ball's boundaries to the width and height of the applet.
//if circle c has been created, do something with it.
// draw image on the screen
g.drawImage (canvas, 0, 0, this);
Above is my overridden update method.
the blue text above is where I call upon the methods of my object c of the "circle" class that I made. it simply draws the circle based on different circumstances.
What I see it is doing is drawing to the off-screen image, correct? well, in order to display an image in the same way, would I use an image and draw that image to the off-screen image?
how is it done?
(thanks to all that are helping me. you guys are great.)