Graphics Programs Reference
In-Depth Information
missile.getDestinationPositionX() > 30 ||
missile.getDestinationPositionY() < -15 ||
missile.getDestinationPositionY() > 15) {
missilesIterator.remove();
} else {
missile.interpolateXY();
}
}
}
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
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

Search WWH ::

Custom Search