Composing SKActions in Xcode 7 – Story Tellers iOS Starter Kit Documentation

Composing SKActions in Xcode 7

Story Tellers iOS Starter Kit 2 Documentation

Xcode 7 introduces the option to visually compose Actions on a timeline. You can do this in the SKScene for your page OR you can create a new Scene file specifically for Actions you’ll name and use later. Which is what you’re seeing in the image below. This is a file called YourActions.sks. Fortunately when using your action later, the file name is inconsequential. All you have to remember is the name of the Action (in this example, it is YourFirstAction). Which is what we would refer to it by in the Property List.

Introduction to Composing SKActions in Xcode 7 and iOS9

By clicking the + icon where the first green arrow is pointing, you’ll create and name your actions.

From there, you’ll simply drag and drop Actions into the timeline. You can change their duration, settings, etc from the Attributes editor on the right. You can even select multiple Actions and make them loop infinitely. Actions make it easy to compose a series of sounds, or sequence of animations all without writing code or setting properties in the kit’s Property List. All we have to do is tell the action to run, or stop. Most likely you’ll want to set up your Actions right on the page you’ll be designing (so you can preview them easily)

Where the Orange arrow is pointing below, you can toggle between Animate and Layout. In Layout mode you can move your nodes around the scene. In Animate mode the timeline will play and you can see the affect of your Actions.

Toggle Animate and Layout in SKAction Timeline editor

Re-using your own SKActions!

The custom Actions you create can be reused. Every time you create an action, it will get added to the Object library. In the image below, the items with dotted square icons are all Actions I created to test things. So these Action references can be dropped back into the timeline and used elsewhere.

Where Custom SKActions go in the iOS9 Kit

If you create a series of Actions in your scene on a specific node and think it is worth saving for later, select all the Actions, right click and choose Convert to Reference. Notice in the screen shot below, there are some other useful options like Cut, Copy, Delete, Duplicate, Reverse (cool!), and Create Loop.

Looping SKActions in Xcode 7

 

 

 

SKActions for Animation

Your most frequented action when building an amazing book app will probably be the AnimateWithTextures Action.

Drag it into the timeline, set your duration, then add frames for the Elements animation sequence. To find the frames to add, you’ll need to switch from the Object Library tab to Media Library tab (where the second arrow is pointing).

You can set up an unlimited number of animations, ready for use later in the app by simply providing the name you chose.

SKAction for AnimateWithTexture

If you stumbled onto this article, it is part of our documentation for the Story Tellers iOS Starter Kit 2. The kit enables you to make children’s book apps and games without writing any code! But it is Swift 2 based and compatible with iOS9 (or higher) and Xcode 7 (or higher), so kit buyers can even extend the functionality to fit their needs further. Some of what we cover in the kit documentation may apply to Xcode in general, so this article could be worth a read even if you aren’t a user. You can purchase Lifetime Updates the kit here, or subscribe Yearly to CartoonSmart and get the latest version, plus access to all of our other kits / tutorials.

We’ve also created an iBook to document the very latest properties in the kit, so be sure to download that as well.