How to program a Role Playing Game with Sprite Kit

For anyone that stumbles onto this blog, you’ll probably be interested in some “premium” video tutorials.  Assorted code snippets are great, but there comes a time for epic learning, and that can best be delivered with a real project and video tutorials.  My latest Sprite Kit lesson is 8 hours long (divided up into shorter 10-20 minute movies) and covers a long-time favorite topic of mine, Role Playing Games!. I’ll give you a brief overview of the lesson below, but you can find out more at the sales page.

Sprite Kit RPG Tutorial

Each level is a physics based world, one thing we will do early on is program our own debug borders around the physics objects. This way we can see exactly what the collision area is around the world, characters, etc. This was an easy option to turn on with Cocos2d, but unfortunately with Sprite Kit, you need to do a little extra programming.

Sprite Kit RPG Tutorial - Using Property Lists

The screen shot above shows part of the Property List we will create during the lesson. This will be used to populate each level, and define dozens of options on a per-character basis. Each character can have their own texture set, with options for side views, back views, front views, resting and attack frames.

Sprite Kit Particle Tutorial

 

We will add Sprite Kit Particle emitters when the character attacks / dies. These are a great addition to Xcode 5 and a lot of fun to play with.

 

 

 

Sprite Kit RPG Tutorial

Once the initial setup is done, we can play around with the physics environment. Sending players, coins, whatever, bouncing around the scene based on physics forces or impulses.

Interested? See more at the sales page for How to Make a Role Playing Game with Sprite Kit.

Or continue reading the entire course outline below…

Session 1 – Introduction to the RPG World

Introduction and Property List Features – 16:58

Video 1 – In this video, we’ll look at various versions of the demo project, each with slight tweaks to the Property List file that drives nearly everything in the published app.

Initial Setup


 – 23:54


Video 2 – In this part of the Sprite Kit tutorial, we will handle most of the initial setup for the project. We import in some images to use early on, setup folders for the texture atlases, create our property list file, constants file and Level / Character classes.

Creating the Physics-Based World


 – 19:51

Video 3 – In this video, we will create a physics-based world with Sprite Kit. This world will contain everything in our role playing game.

Creating the Physics-Based World (continued) – 


22:45

Video 4 – Next we will add a character inside of the physics world. To test the physics we will add gravity (later we will disable it), and this will give us an opportunity to test the contact listener delegate and get feedback from the level class when our character collides with a wall.

Session 2 – Property Lists, Debug Borders, Gestures & More

Using the Property List Data – 19:14

Video 5 – In this tutorial we will begin using some of the data stored in our Property list file to populate elements in the game.

Adding Debug Boundaries for the Physics Objects – 26:32

Video 6 – In this tutorial we will add visible paths around our Sprite Kit physics objects. This will help in debugging exactly when objects touch and show us the physics boundaries when we resize to something other than 100% of their corresponding image sizes.

Adding Gesture Recognizers to the Sprite Kit View – 10:53

Video 7 – In this video, we will add Gesture Recognizers to detect a swipe up, down, left, right, or a one, two or three finger tap, as well as a rotation recognizer.

Bringing in Other Characters from the Property List – 13:37

Video 8 – In this video we will bring in other characters to our Sprite Kit world by parsing through the property list, determining if there is more than one item in the array, then adding that character.

Session 3 – Follow the Leader

The Update Methods and Initial Directional Movements – 24:45

Video 9 – In this video we will begin using the update method of the level class to essentially “run” the game and control if everything is paused or not. In turn, this will be used to fire each character’s update method. We will also begin setting the initial directional movements for each character.

Delayed Followers – 20:33

Video 10 – In this video, we will setup a delay for the movements of everyone but the leader. We’ll also rotate the characters to face different directions as they move.

Stopping the Characters – 20:28

Video 11 – In this video we will learn how to stop the characters and make them fall into position.

Enabling Characters on Contact with the Leader – 22:59

Video 12 – In this video, we will define which characters follow the leader by default versus which will need contact with the leader before joining the team.

Session 4 – Textures for Front, Back and Side Views.

Setting up the rest of the Property List – 12:38

Video 13 – In this video, we will setup the properties we need for the rest of the series. This includes the SKTextureAtlas frames, health options, speed and more.

SKActions for Changing the Textures of the Character – 22:02

Video 14 – In this video, we will setup the SKActions used to show texture changes during the walk cycles. We’ll look at SKTextureAtlas and SKTexture class.

Running the SKActions for Front, Back and Side view Walk Sequences -17:17

Video 15 – Once the SKActions have been created for each possible direction to walk, we will write the code to actually run the SKActions (if they aren’t nil). We will also change the zRotation and zPosition as needed for each view.

SKActions for Attacking – 13:23

Video 16 – In this video, we will use the tap Gesture recognizer to attack, which will call our attack SKActions for various views.

Session 5 – Particles, Health Meters, and Receiving Damage

Particle Emitters – 16:13

Video 17 – In this video we will create a Sprite Kit Particle File, and add it as an effect when the character attacks. We’ll setup some properties in the .sks file, and change other properties at runtime using the plist.

Health Meters and Receiving Damage – 19:44

Video 18 – In this video we will create SKSpriteNodes for our health meters, and make the characters get damaged if they hit a boundary.

Game Over – 18:32

Video 19 – In this lesson, we will create a method to transition back to the Start Menu if the lead player dies and doesn’t have any following players. Otherwise, the follower will take over the lead position.

Switching Leader Order – 7:32

Video 20 – In this tutorial, we will use two or three finger taps to switch out the leader with either the second or third player in the character chain. You can extend this to 4, 5, 6, etc taps.

Session 6 – Instruction Text, Bouncing Off Walls & More

Fading Instruction Text – 14:38

Video 21 – In this video we will add an SKLabelNode, and write a conveinence method to handle fading and removing any SKNode.

Bouncing Back From Wall Contact and Flaming to Death – 22:59

Video 22 – In this tutorial, we will modify the code to bounce back any character that gets damaged by the wall. We will also add a Sprite Kit particle emitter to flame out the character while dying off.

Collecting Coins – 23:38

Video 23 – In this tutorial, we will create a new class for coins, then have the character collect them using the physics contact listener.

Advancing Levels – 10:25

Video 24 – In this tutorial we will using a static variable to keep count of the current level to load from the property list, and work on advancing levels when every coin has been collected.

Alternate Property List Locations for the iPhone or iPad – 15:26

Video 25 – In this tutorial, we will add options IF you want to provide alternate locations for the iPhone or iPad devices. If no alternative is provided the kit will use a default location.

Resizing the Entire SKScene – 7:05

Video 26 – In this tutorial, we will resize the Sprite Kit scene, which is the easiest way to scale up or down the entire world without having to account for a scale factor with our SKPhysicsBodies.

Creating an SKLabelNode for Stats – 4:55

Video 27 – In this tutorial we will create an SKLabelNode which will count the number of coins collected. This will be included in our world instance, so we will move the label as the leader moves (which makes it appear to stay in one place).

Applying Physics Force and Impulses to Scatter Coins – 11:50

Video 28 – In this tutorial, we will play around with some Sprite Kit physics properties and methods by bouncing coins around the scene (great inspiration for many other games.)

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s