June 2013
Intermediate to advanced
346 pages
8h 42m
English
Now we can start writing our object builder class. Let’s create a class in the package com.airhockey.android.objects called ObjectBuilder. Start out with the following code inside the class:
| AirHockeyWithImprovedMallets/src/com/airhockey/android/objects/ObjectBuilder.java | |
| | private static final int FLOATS_PER_VERTEX = 3; |
| | private final float[] vertexData; |
| | private int offset = 0; |
| | |
| | private ObjectBuilder(int sizeInVertices) { |
| | vertexData = new float[sizeInVertices * FLOATS_PER_VERTEX]; |
| | } |
There’s nothing too fancy here so far. We’ve defined a constant to represent how many floats we need for a vertex, an array to hold these vertices, and a variable to keep track of the position in the array ...
Read now
Unlock full access