Game Development Reference
In-Depth Information
Geometric relations involved in the updateLocation task
5-5
, we see the X and the Y axis with the origin on the upper left and the positive Y axis
theta
is calculated based on the values of
,
dy
, and the location of the move to point. The black arrow is of length speed and shows where
dxf
and
dyf
are
calculated based on the angle.
Responding to a User Tap
We now know we can make the ship move, one frame at a time. But we have not looked at how we
tell the ship where to move. Recall that we registered a
UITapGestureRecognizer
on the root
UIView
of
Example01Controlller
. This
UITapGestureRecognizer
is configured to call the task
viewTapped:
.
This is shown in Listing 5-6.
Listing 5-6. Example01Controller.m (viewTapped:)
-(void)viewTapped:(UIGestureRecognizer*)aGestureRecognizer{
UITapGestureRecognizer* tapRecognizer = (UITapGestureRecognizer*)aGestureRecognizer;
CGPoint tapPoint = [tapRecognizer locationInView:self.view];
[viper setMoveToPoint: tapPoint];
}