Wishlisted Wishlist

Please confirm that you want to add Role Playing Games with Sprite Kit: Heroes to your Wishlist.

Add to Wishlist

Role Playing Games with Sprite Kit: Heroes

Learn how to build a physics based hero inside of a basic top-down view level. All with Sprite Kit & property lists.
4.4 (32 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
4,826 students enrolled
Created by Justin Dike
Last updated 10/2013
  • 8 hours on-demand video
  • 1 Article
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion

In this first series of lessons on Sprite Kit based role playing games, we will create a physics-based world with a roaming hero that can collide with other heroes (and make them follow the leader). Nearly everything will be property-list driven (adjustable by changing text in a plist file) and we'll program options for each character to include / exclude front view animation, side view animation or back view animation. We will look at making the character attack, emit particles, receive damage, have a health meter, advance levels, restart levels and much, much more! All using Xcode 5 and Sprite Kit.

Who is the target audience?
  • Anyone
Students Who Viewed This Course Also Viewed
What Will I Learn?
By the end of this course you will have the foundation of countless Role Playing Games with Sprite Kit
View Curriculum
  • Mac with Xcode 5
Curriculum For This Course
Expand All 29 Lectures Collapse All 29 Lectures 08:01:18
Introduction to the RPG World
4 Lectures 01:23:28

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. Of note, you can:

  • Change physics shapes for the character (square or circle)
  • Alter the size of the physics shape
  • Choose to enable or disable front, side or back view walk animations (as well as attack frames for each view)
  • Enable debug mode for each character or the background to see exactly where the physics bodies are defined.
  • Change the frame rate of the animates for each character.
  • Enable or disable health meters.
  • Set particle animations for each character's attack mode.
  • Change the style and reaction time for how the characters follow the leader.
Introduction and Property List Features

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.

Initial Setup

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

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.

The project as it was at the end of this video, has been added to the Supplemental Materials tab.

Creating the Physics-Based World (continued)
Plists, Debug Borders, Gestures and More
4 Lectures 01:10:16

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

Using the Property List Data

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 Debug Boundaries for the Physics Objects

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.

Adding Gesture Recognizers to the Sprite Kit View

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.

You can download the project as it was at the end of this session by going to the Supplemental Materials tab.

Bringing in Other Characters from the Property List
Follow the Leader
4 Lectures 01:28:45

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. This will also be used to fire each character's update method. We will also begin setting the initial directional movements for each character.

The Update Methods and Initial Directional Movements

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.

Delayed Followers

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

Stopping the Characters

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.

The project at the end of this session has been added to the Supplemental Materials tab.

Enabling Characters on Contact with the Leader
5 Lectures 01:05:45

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

The Source_Images.zip file in the Supplemental Materials tab has all the textures for the rest of the tutorial.

Setting up the rest of the Property List

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.

SKActions for Changing the Textures of the Character

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.

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

Notes for iOS8.1

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

The project at the end of this session has been uploaded to the Supplemental Materials tab.

SKActions for Attacking
Particles, Health Meters, and Receiving Damage
4 Lectures 01:02:01

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.

Particle Emitters

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

Health Meters and Receiving Damage

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.

Game Over

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.

You can download the project as it was at the end of this session by going to the Supplemental Materials tab.

Switching Leader Order
Instruction Text, Bouncing Off Walls and More
8 Lectures 01:50:56

In this video we will add an SKLabelNode and fade it into the background.

Fading Instruction Text

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

Bouncing Back From Wall Contact and Flaming to Death

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

Collecting Coins

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.

Advancing Levels

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.

Alternate Property List Locations for the iPhone or iPad

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.

Resizing the Entire SKScene

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).

Creating an SKLabelNode for Stats

In this tutorial, we will play around with some Sprite Kit physics properties and methods by bouncing coins around the scene. Possibly inspiring you to create some fun games.

The final project files have been uploaded in the Supplemental Materials tab.

Applying Physics Force and Impulses to Scatter Coins
About the Instructor
4.3 Average rating
533 Reviews
39,498 Students
24 Courses
CartoonSmart / Owner / Leader Developer and Instructor

Justin Dike is the founder of CartoonSmart one of the internet's first video training websites. He is a long-time illustrator and animator, focusing mostly on Adobe Flash, and experienced programmer with Swift, Sprite Kit, Actionscript 3, Objective C and Cocos2d. For CartoonSmart he has recorded hundreds of hours of video tutorials and recently published his first full length book titled iOS Programming with Xcode and Cocos2d available in the iBookstore. Justin has also developed many iOS games, including a side scrolling game engine.

Report Abuse