greatwar93 / gwt-g2d

Automatically exported from code.google.com/p/gwt-g2d
0 stars 0 forks source link

draw images on surface #21

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

i am trying to make a small game with g2d :
I have a surface which represents my field.
I draw an image on the surface for the background.

With a FpsTimer, i update the surface every 0,1 secondes.
when i update, i clear the surface and i draw several images on the surface.

1) how can i avoid that the clear method of the surface delete the 
imageBackground, in order to avoid drawing again the background every 0,1 
secondes?
Is there another way to fix the image bacground on the surface, like putting it 
on the contentPanel of the surface (but in this case as the contentPanel is a 
FlowPanel i can't draw the background at the same place that the surface).
I tried to use other kind of Panel instead of FlowPanel but it seems that's 
can't work.

2) instead of clearing the surface and drawing the images on each update, could 
i create CanvasElements to represents my Images and give them something like a 
path (with a ShapeBuilder or other things)?

Thanks a lot for your great work and please excuse my poor english.

Original issue reported on code.google.com by arnaud.c...@yahoo.fr on 5 Apr 2011 at 9:06

GoogleCodeExporter commented 8 years ago
You can create multiple Surfaces and put them on top of one another to create 
layers - use the bottom layer to draw background only and upper layers to draw 
other things.  You won't have to redraw the bottom layer if the background is 
static.

One way to put multiple Surfaces in the same place is to use an AbsolutePanel.  
If two Surfaces starts from the same (x, y) coordinate and have the same size, 
you won't notice that there are two of them (unless you look at the source).

Original comment by hao1...@gmail.com on 5 Apr 2011 at 2:43