This page contains a Flash digital edition of a book.
GAMES DESIGN // GRAPHICS AND ANIMATION | BETA


Honey, I shrunk the pictures!


Nikolas Banspach of InnoGames provides a how-to of graphics and animation loading in Flash games, using the developer’s Forge of Empires as a case in point for what can be done with a few tidy tricks


PLAYERS EXPECT modern browser games to have increasingly complex game mechanics and high quality graphics. Thus, at InnoGames we created well over 200


partially-animated buildings for the Forge of Empires’ city view. Even with these, however, the loading time for those with slower DSL lines or poor quality connections has to remain on a bearable level. Creating a smooth gaming experience was one of the most important requirements for the development team. Long waiting times at the start or during the game should always be avoided. At the same time, however, the sophisticated optics require a number of bandwidth-hungry bitmap graphics. So how do developers bring this all under one roof?


If a team is like us and has several


hundred graphics for GUI elements, it is important to look early for ways to reduce their weight.


Nikolas Banspach, InnoGames


We did this by making Forge of Empires a modular design. First, only a relatively small main application is started. This in turn signals for the first resource package that includes graphics for the interface and dialogs, which are essential for the game. All other images are retrieved only when needed by the servers, and are mostly stored in resource bundles together. By doing this, one can effectively reduce the number of requests to the server and use the LZMA compression, introduced in Flash Player 11.2. But also entire parts of the program – for example the campaign map and battle are each being put into separate modules – which will only get requested after a corresponding user action. Despite the abandonment of some features in


Forge of Empires, such as the rotation of buildings – because of the shadow, buildings cannot be mirrored in the memory that easily –we had to use some trickery to reduce the amount of data. Over the next two pages I’ve provided some tips that could be useful for similar projects.


DEVELOP-ONLINE.NET


BUILDING ANIMATIONS The production buildings in Forge of Empires are not initially animated. Only when production is started do the little structures come to life: the printer's press jumps into motion and a butcher goes to work. This obviously invites one to simply separate graphics and animations of the buildings. In the first step, we loaded a static graphic for each building. As an animation format, we used sprite sheets instead of the timeline animation, which is generally more common in the flash world. These included the juxtaposed frames of animation. The advantage of this solution is a higher flexibility of animation speeds, which would not be possible with a frame-synchronised animation. The building itself, however, is no longer included in the sprite sheets, but only the deviation of the pixels to the graphics. In front of the tavern, two very happy visitors were rendered and in the post-processing automatically cropped. When the buildings and the sprite sheet were


loaded, the individual sprites were cut from the sheet. They were then placed over the building and this produced the animation.


SPRITE SHEETS FOR GUI ELEMENTS If a team is like us and has several hundred graphics for GUI elements, it’s important to look early for ways to reduce their weight and still keep track of the respective images. The individual components for us were therefore also combined to sprite sheets, and our asset management was expanded to include methods to trim them and make the sprites to be available in a definite name. Figure 1 (next page, right) shows a sprite sheet for a button. It contains all the relevant states: ‘up’, ‘hover’ and ‘down’. Within the asset packages, definite names are being distributed with the use of XML and the cutting is defined:


image name="plus_button_normal" src="button_sheet" cropx="30" cropy="0" cropwidth="30" cropheight="30"/> <image name="plus_button_hover" src="button_sheet" cropx="30" cropy="30" cropwidth="30" cropheight="30"/> <image name="plus_button_down" src="button_sheet" cropx="30" cropy="60" cropwidth="30" cropheight="30"/>


The above is repeated for the minus button.


Sprite sheets were used to animate buildings in InnoGames’ Flash title Forge of Empires


AUGUST 2012 | 75





Page 1  |  Page 2  |  Page 3  |  Page 4  |  Page 5  |  Page 6  |  Page 7  |  Page 8  |  Page 9  |  Page 10  |  Page 11  |  Page 12  |  Page 13  |  Page 14  |  Page 15  |  Page 16  |  Page 17  |  Page 18  |  Page 19  |  Page 20  |  Page 21  |  Page 22  |  Page 23  |  Page 24  |  Page 25  |  Page 26  |  Page 27  |  Page 28  |  Page 29  |  Page 30  |  Page 31  |  Page 32  |  Page 33  |  Page 34  |  Page 35  |  Page 36  |  Page 37  |  Page 38  |  Page 39  |  Page 40  |  Page 41  |  Page 42  |  Page 43  |  Page 44  |  Page 45  |  Page 46  |  Page 47  |  Page 48  |  Page 49  |  Page 50  |  Page 51  |  Page 52  |  Page 53  |  Page 54  |  Page 55  |  Page 56  |  Page 57  |  Page 58  |  Page 59  |  Page 60  |  Page 61  |  Page 62  |  Page 63  |  Page 64  |  Page 65  |  Page 66  |  Page 67  |  Page 68  |  Page 69  |  Page 70  |  Page 71  |  Page 72  |  Page 73  |  Page 74  |  Page 75  |  Page 76  |  Page 77  |  Page 78  |  Page 79  |  Page 80  |  Page 81  |  Page 82  |  Page 83  |  Page 84  |  Page 85  |  Page 86  |  Page 87  |  Page 88  |  Page 89  |  Page 90  |  Page 91  |  Page 92  |  Page 93  |  Page 94  |  Page 95  |  Page 96  |  Page 97  |  Page 98  |  Page 99  |  Page 100