There are two example projects that accompany this chapter, and they are described in the following sections.
This is a very simple example demonstrating the use of build styles, resource templates, and deployment types. It is based on the Graphics2D example from Chapter 2, Resource Management and 2D Graphics Rendering.
The resbuildstyles.itx
file defines a build style called highres
that specifies a prefix directory called data-highres
. If you look inside the data
directory, you will see that the jar of the marmalade image in dataimages exturesmarmalade.png
is 256 x 256 pixels in size. A new directory for the highres
build style has also been added, containing a 512 x 512 version of this image. This file is called datadata-highresimages exturesmarmalade.png
.
If you now look at the app.icf
file, you will see the new entry ResBuildStyle=highres
. If you run the program with this line in place, the 512 x 512 version of the image will be loaded. Comment out or remove this line, and the 256 x 256 image will be loaded.
The restemplates.itx
file shows a simple example of a resource template that will force the images to be converted into RGBA4444 format and also disables mipmapping. This resource template is used in the dataimagesimages.group
file to reduce the size of the images.group.bin
file as no mipmap images need to be stored in it.
Finally, the BuildStyles.mkb
file declares two deployment types called normal
and highres
. When making an install package using the Marmalade System Deployment Tool, we can select either of these options to include the low or high resolution images. Note that the deployment tool will also list the default deployment type as this is always defined automatically by the deployment tool. Using the default type will not include any resources and so will not work on the device.
For this chapter the Skiing project has been updated to use build styles, resource templates, and deployment types. It also makes use of Derbh archives to reduce the size of the install package.
In this instance the build styles system has been used to allow a larger size of font to be used on devices with a higher screen resolution. The datadata-highresuifonts
directory contains alternative versions of the font files skiing.gxfont
and skiing.tga
that will be loaded when the highres
build style has been selected in the app.icf
file.
No changes were necessary to any of the UI layout configuration since we used the approach of sizing controls based on the screen dimensions of the device. We just need a slightly bigger sized font to fill the larger screen area better.
To make deployments easier and to reduce the overall memory size of install packages, the Derbh API has also been used. If you look in the root project directory, you will see two new files called skiing.dcl
and skiing-highres.dcl
. These files list all the resources needed by the game and are used as input to the DZip tool to create the archive files. A batch file called MakeDerbh.bat
has also been included to demonstrate use of the DZip tool.
Note that the Derbh archives can obviously not be created until the various .group.bin
files have been generated. In order to do this you will need to run the game twice, once with the ResBuildStyle=highres
setting set in the app.icf
file and again with this line commented out.
The two DCL files create the target archives inside the data-ramdata-gles1
and data-ramdata-highres
directories, but both generate an archive called skiing.dz
. The deployment types in the Skiing.mkb
file include the relevant version of this file so our code becomes independent of the deployment type. At the start of the program we just have to attach the skiing.dz
archive with the dzArchiveAttach
function in order to access the correct resource files.
18.225.234.24