Graphics Programs Reference
In-Depth Information
missile.getDestinationPositionX() > 30 ||
missile.getDestinationPositionY() < -15 ||
missile.getDestinationPositionY() > 15) {
} else {
This will allow us to obtain the center of the missile which has just been fired. As
the angle of the tank is also the angle of the missile, using the angle ( zAngle ) and
the center ( missileCenter ) we can initialize a Missile object and add it to the
_missiles ArrayList .
When the fire button is pressed, inside the onClick() handler for the fire button
(class Main ), the static field GLES20Renderer._buttonMissilePressed
is set to true. This allows for the execution of code inside the
if(GLES20Renderer._buttonMissilePressed){...} block - as
shown in Listing 6-15 . Here, a Missile object is instantiated and is then added
to the _missiles ArrayList . Finally, by using a ListIterator we iterate
over the missiles in the _missiles ArrayList , and then check if any missile is
outside the specified bounds. If it is inside, then its position is interpolated ( Listing
6-15 , Figure 6-6 ), else it is removed from the ArrayList .
Search WWH ::

Custom Search