Game Development Reference
In-Depth Information
Next is the last inner class called AssetLevelDecoration . It contains all the
decorative images that only add to the look and feel of the level. This collection
of assets consists of three differently shaped clouds ( cloud01.png , cloud02.png ,
and cloud03.png ), a very wide mountain that spans across two image halves
( mountain_left.png and mountain_right.png ), and an overlay ( water_overlay.
png ) that will be stretched along the x axis to give the illusion of water existing
everywhere in the game world.
The overlay image for the water could have been shrunk down to
a total width of one pixel because the content repeats on the x axis
along which we plan to stretch it anyway. Furthermore, it makes no
difference to the render performance how far an image is stretched.
However, it is easier to show you an image in a printed topic that is
wider than one pixel.
Add the following inner class to the Assets class:
public class AssetLevelDecoration {
public final AtlasRegion cloud01;
public final AtlasRegion cloud02;
public final AtlasRegion cloud03;
public final AtlasRegion mountainLeft;
public final AtlasRegion mountainRight;
public final AtlasRegion waterOverlay;
public AssetLevelDecoration (TextureAtlas atlas) {
cloud01 = atlas.findRegion("cloud01");
cloud02 = atlas.findRegion("cloud02");
cloud03 = atlas.findRegion("cloud03");
mountainLeft = atlas.findRegion("mountain_left");
mountainRight = atlas.findRegion("mountain_right");
waterOverlay = atlas.findRegion("water_overlay");
}
}
So far, we have established a way to group our assets in logic units, which also cache
their references after their initial lookup. What is still missing is the code that uses
our new inner classes.
Add the following two imports to the Assets class:
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
 
Search WWH ::




Custom Search