Book Image

iOS Game Programming Cookbook

Book Image

iOS Game Programming Cookbook

Overview of this book

Table of Contents (19 chapters)
iOS Game Programming Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Movement of players


Once the environment for multiplayer is ready, it's time for the actual action: making the player move when a user touches or drags on screen. As it's a multiplayer game the movement is to be synced with the remote device, which a good challenge and a magical thing to experience.

Getting ready

Before starting with this section we should be aware of the touch methods of SKScene like touchBegan, touchMoved, and touchEnded as all the movement will be done on the basis on touch. Also we should be good at mathematics, as this movement of tanks with its head to be in the direction of touch, has to be done and synced with the remote device. In this section, we will be implementing the movement of tanks and also syncing the movement on other device by sending and receiving network packets.

How to do it

Following are the steps involved in making a tank move on touch and also sync on a remote device by sending and receiving packets:

  1. On touching the screen, these methods of SKScene are...