I'm not sure this a "best practice" issue as such - I think you may
have more of an "edge case" here. I've tried your game (although I
can't understand what to do after first screen), but what happens is
that the browser is slogging away downloading data (presumably your
images) which gives gutter messages and hour glasses etc. This is very
distracting, but if you had to wait for the whole lot to download
before the game started you'd probably get bored and go somewhere
else.

I would have thought the best approach might be to download the images
as required for each level as the player advances through the game,
and I would think displaying a "Loading area..." type message after
they have completed a level is a traditional approach for games,
especially giving them something to read whilst they are waiting.

This approach is not so well served by GWT because AFAIK you can only
have one ImageBundle per module and in any case it is downloaded on
initial page load. You may find this thread interesting:

http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/1106bc10356e9880/60fc5167fe4b1040?lnk=gst&q=multiple+module+bruce+ian+buffoon#60fc5167fe4b1040

In it Bruce Johnson comments:

4) History is the answer to apps that are "too big". If you combine
the
points from #2 and #3 above, hopefully it makes sense that whenever
you fear
your app is becoming "too big" for a single page, all you need to do
is
split it into multiple pages such that each page has a unique module
with a
unique entry point. History smooths all the page junction points, and
the
compiler is smart enough to eliminate code you don't use from each
page's
entry point(s).

Which would appear to answer the one ImageBundle per module issue and
provide convenient inter-level load points. However I would also read
what Reinier has to say about it as he also knows what he's talking
about. It would certainly complicate your program.

Failing that, you could consider handling image strips yourself. You
assemble a single composite image manually of all images required for
a single level in some convenient extraction grid. Then you use an
Image object for this composite image, but before you give it the URL,
you attach a LoadListener to it - this is so can tell when its
finished loading in your code and control the loading message and the
UI during level load procedure and kick off extracting the individual
image parts etc.

It's a bit tricky to extract bits of one image to create several
others in your own code. I did it once for an experiment, it looked
like this:

Image sampleImage = new Image(someURL)
.....
.....
    HTML box = new HTML();
    Node imageClone = sampleImage.getElement().cloneNode(false);
    box.getElement().appendChild(imageClone);
    grid.setWidget(i, j, box);
    Image part = Image.wrap((Element)imageClone);
    part.setVisibleRect(7,7,10,10);

The problem I found is that you can use an <img> Element to make a new
Image object (which you can then clip), but it must be attached to the
DOM already, hence the messing about. This works, but I make no claim
that it is the most, or even a reasonably, efficient way to do it.
There may be a much better way to do this in GWT, or you may find that
you can do it better in javascript and use a JSNI interface. It might
be worth searching the javascript forums for some ideas, as I'm sure
this has been done before.

regards
gregor





On Feb 4, 1:37 pm, darkflame <darkfl...@gmail.com> wrote:
> No, this is a large number of very large images, bundles are not
> approporate as that would mean they would all be loaded at once, and
> the user would have to effectively preload the whole game.
> This is not about icons, but actual images. (as it, 640x480 or in some
> case's much larger).
>
> On Feb 4, 10:42 am, doopa <niallhas...@googlemail.com> wrote:
>
> > Hi,
>
> > The key is to use ImageBundles or use one large image that contains
> > all the icons you want to use and then draw only parts of them when
> > you want it displayed.
>
> >http://code.google.com/p/google-web-toolkit/wiki/ImageBundleDesign
>
> > How that helps.
>
> > On Feb 3, 5:50 pm, darkflame <darkfl...@gmail.com> wrote:
>
> > > I have quite a large app being developed, and requires various large
> > > images to be displayed at certain times.
>
> > > As the app (rather, a educational game) has a login screen, it makes
> > > sense to start loading the images while the user is login in, and in
> > > the order of the images appearance.
>
> > > I thought I handled this ok with a while loop, going over a list of
> > > images and using ;
> > > Image.prefetch(URL);
> > > To get the images ready.
>
> > > However, from what I can tell, this is slowing down some systems (CPU
> > > wise). I think this is because I'm effectively telling all the images
> > > to load at once without a pause.
> > > Whats the best practice for loading a large number of images in a set
> > > order?
>
> > > You can actualy see the game 
> > > here;http://www.cuyperscode.com/CuypersCode2/CCIIstart.html
> > > But its in Dutch.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to