GwtCanvasDemo Question

49 views
Skip to first unread message

Sean

unread,
Jun 23, 2011, 7:35:18 PM6/23/11
to google-we...@googlegroups.com
So I am making a simple card game using GWT. It works, it's nice, but it isn't very flashy. So my plan is to have a Canvas sit below the cards and when a card is played have a special effect animation on the canvas run. I'm looking at the GWTCanvasDemo @ http://code.google.com/p/gwtcanvasdemo/source/browse/trunk/src/com/google/gwt/gwtcanvasdemo/client/GwtCanvasDemo.java. I've downloaded the code, I've run it, it works....and I have no idea how.

There are two canvaes, canvas and backbuffer. The canvas has the lens with the warp effect, the back buffer has all the images / balls drawn on them. However, the backBuffer never seems to be added to the Rootpanel. It's also never given a size like canvas is, it's only given Coordinate Space. I'm trying to mess with this code in my own project and I can't figure out how and why the demo works. Can someone explain to me what's going on?

Philip Rogers

unread,
Jun 24, 2011, 8:44:16 AM6/24/11
to google-we...@googlegroups.com
Hi Sean,

It's definitely not the cleanest code for understanding! The magic happens in lens.java::draw(backbuffer, frontbuffer). What's happening is the lens calls:
front.drawImage(back.getCanvas(), 0, 0);
which copies (blits) all the pixels from the back to the front. The backbuffer is never added to the root panel because it's only used as a temporary store of pixels for this operation.

By the way, if you're interested in high performance javascript games, you may be interested in the ForPlay project. It's built using GWT and is targeted at multiplatform (including Html5) games.

Sean

unread,
Jun 24, 2011, 8:53:06 AM6/24/11
to google-we...@googlegroups.com
Ah, I see. Thanks Phillip! And also thanks for the link to ForPlay, I will definitely check it out!
Reply all
Reply to author
Forward
0 new messages