Java Reference
In-Depth Information
private static final int kLeft = 1;
private static final int kRight = 2;
private static final int[] kRunningSequence = { 0, 1, 2 };
private static final int[] kStandingSequence = { 3 };
public QuatschCanvas(String quatschImageName,
String atmosphereImageName, String backgroundImageName)
throws IOException {
super(true);
// Create a LayerManager.
mLayerManager = new LayerManager();
int w = getWidth();
int h = getHeight();
mLayerManager.setViewWindow(96, 0, w, h);
createBackground(backgroundImageName);
createAtmosphere(atmosphereImageName);
createQuatsch(quatschImageName);
}
private void createBackground(String backgroundImageName)
throws IOException {
// Create the tiled layer.
Image backgroundImage = Image.createImage(backgroundImageName);
int[] map = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
1, 2, 0, 0, 0, 0, 0, 0,
3, 3, 2, 0, 0, 0, 5, 0,
3, 3, 3, 2, 4, 1, 3, 2,
6, 6, 6, 6, 6, 6, 6, 6
};
mBackground = new TiledLayer(8,6, backgroundImage, 48, 48);
mBackground.setPosition(12, 0);
for (int i = 0; i < map.length; i++) {
int column = i % 8;
int row = (i - column) / 8;
mBackground.setCell(column, row, map[i]);
}
mAnimatedIndex = mBackground.createAnimatedTile(8);
mBackground.setCell(3, 0, mAnimatedIndex);
mBackground.setCell(5, 0, mAnimatedIndex);
mLayerManager.append(mBackground);
}
Search WWH ::




Custom Search