
Explore how external game controllers and the micro gamepad enhance two-player tvOS battles on Apple TV, including disconnect handling and setting up a two-player game in code.
Discover how to connect an extended gamepad controller in a two-player tvOS game, set up controller observers, assign player indices, and handle gamepad inputs.
Learn to connect standard and micro gamepads to a tvOS two-player game, test d-pad and thumbstick input, and map buttons for jump, fire, pause, and menu.
Move a tank in a tvOS game using the extended controller or micro gamepad, with the left thumb stick for movement and the right for turret rotation.
Learn to rotate the turret using the right thumb stick on extended and micro gamepads, implementing rotation in update with a rotation out, speed adjustments, and compatibility for standard controllers.
In this lecture, you implement one-player firing by creating bullet sprites with physics bodies, calculating launch positions, applying force vectors, and adding a firing cooldown for two-player readiness.
Learn how to handle multiple controllers in tvOS by indexing players, prioritizing extended and micro-controller connections, and ensuring each controller controls a distinct character while pausing on disconnect.
Extend your game to support a second player by duplicating tank assets, labeling players as green and blue, and creating a custom tank class to manage color-specific behavior.
Learn to set up the second player in a tvOS game by mapping the blue turret controls to the correct game pad index and simplifying the player switch logic.
Enable second-player firing by passing the correct tank into create bullet, implement green/blue can-fire logic, and tune bullet speed and turret rotation for responsive multiplayer action.
Implement a one-player mode with a cpu-controlled second player, including forced one-player options, controller checks, and loops for enemy firing, movement, and turret rotation.
Learn to switch between one-player and two-player modes by detecting multiple controllers, managing one-player loops, determining the active player on disconnect, and implementing pause prompts for a tvOS game.
Learn to switch between 1-player and 2-player modes in a tvOS game by implementing pause controls and showing or hiding controller labels based on connected controllers.
Implement a pause screen for player-vs-player tvOS games that lets players resume or return to the main menu, handling remote and controller inputs to navigate and select options.
Learn to build a tvOS main menu by creating a home scene, wiring controllers, and handling one player or two player transitions while preserving background music.
Learn to implement physics collisions in tvOS games by configuring the SK physics contact delegate, defining category bit masks, and handling tank–bullet contacts with didBeginContact.
Create a custom bullet class (sprite node) moved by update with x and y amounts, using image textures to show green or blue bullets and support ricochet against walls.
Learn to trigger a sprite explosion when two tanks collide in a tvOS game by dynamically creating an atlas-based explosion at the contact point, using SKAction sequences and textures.
Test bullet-tank collisions by passing a bullet class, destroy bullets on impact, and implement a lose life sequence with explosions, score handling, and board resets for blue and green tanks.
Load the next level after a 1.5 second delay by passing the current level, enforce max levels, and fade to the scene; add green and blue lives labels for players.
Learn to keep the camera centered between two players by computing the midpoint of their x positions, updating per frame, and handling optional camera setup in the game scene.
Add vertical and horizontal walls in a SpriteKit game to bounce bullets using physics bodies and collision masks, handling didBegin contact and off-screen removal, with one- or two-player modes.
Update collision and contact bit masks in Xcode, configure tank and bullet wall masks, test missiles on Apple TV, and prepare recordings and previews for App Store submission.
***SOURCE PROJECT FILES UPDATED FOR SWIFT 3 (see change notes below)
In the first section of videos, you'll learn how to find connected controllers, define which buttons do what, set player indexes (i.e. Player 1, Player 2, etc) and work with a basic character.
In section 2, you'll learn the Swift / Sprite Kit code to work with multiple Extended / Standard Gamepad controllers (as well as the Micro Gamepad controller), to go head to head versus players in the same room. After we look at the finer points of connecting and disconnecting controllers and getting each in the right player slot, we'll discuss how to control who is who in any type game, and even go into a one-player mode where the CPU takes control of the second player. This way your two-player game can also be enjoyed by single players. We'll also discuss adding a Pause menu to your game, where players can go back to a Main menu or keep on playing.
Now that we've covered all our bases in terms of controlling each player and dealing with controllers disconnecting and reconnecting, section 3 allows us to have some fun. This session we'll loosen things up a bit and just talk game play. Topics include collision detection, decrementing health, losing lives / restarting rounds, and other topics worthy of a good two-player game!
***CHANGE NOTES FROM SWIFT 2 to 3
We've included updated source files for Swift 3. If you choose to follow along, line-by-line with the video code, you should have no problems, as Xcode 8 will auto-suggest the correct code for Swift 3.