How does SpriteKit handle animations and what are actions used for?

Some actions are completed in a single frame of animation, while other actions apply changes over multiple frames of animation before completing. The most common use for actions is to animate changes to the node’s properties. For example, you can create actions that move a node, scale or rotate it, or make it transparent. However, actions can also change the node tree, play sounds, or even execute custom code.
Actions are very useful, but you can also combine actions to create more complex effects. You can create groups of actions that run simultaneously or sequences where actions run sequentially. You can cause actions to automatically repeat.
Scenes can also perform custom per-frame processing. You override the methods of your scene subclass to perform additional game tasks. For example, if a node needs to be moved every frame, you might adjust its properties directly every frame instead of using an action to do so.
SKAction reference for more information.
Add Physics Bodies and Joints to Simulate Physics in Your Scene
Although you can control the exact position of every node in the scene, often you want these nodes to interact with each other, colliding with each other and imparting velocity changes in the process. You might also want to do things that are not handled by the action system, such as simulating gravity and other forces. To do this, you create physics bodies (
SKPhysics) and attach them to nodes in your scene. Each physics body is defined by shape, size, mass, and other physical characteristics. The scene defines global characteristics for the physics simulation in an attached
SKPhysics object. You use the physics world to define gravity for the entire simulation, and to define the speed of the simulation.
When physics bodies are included in the scene, the scene simulates physics on those bodies. Some forces, such as friction and gravity, are applied automatically. Other forces can be applied automatically to multiple physics bodies by adding
SKField objects to the scene. You can also directly affect a specific field body by modifying its velocity directly or by applying forces or impulses directly to it. The acceleration and velocity of each body is computed and the bodies collide with each other. Then, after the simulation is complete, the positions and rotations of the corresponding nodes are updated.
You have precise control over which physics effects interact with each other. For example, you can specify that a particular physics field node only affects a subset of the physics bodies in the scene.

Create 2D sprite-based games using an optimized animation system, physics simulation, and event-handling support.
- iOS 7.0+
- macOS 10.9+
- tvOS 9.0+
- watchOS 3.0+
SpriteKit is a graphics rendering and animation infrastructure that you can use to animate arbitrary textured images, otherwise known as sprites. SpriteKit provides a traditional rendering loop that alternates between determining the contents of and rendering frames. You determine the contents of the frame and how those contents change. SpriteKit does the work to render that frame efficiently using graphics hardware. SpriteKit is optimized for applying arbitrary animations or changes to your content. This design makes SpriteKit more suitable for games and apps that require flexibility in how animations are handled.
Sprite Content is Drawn by Presenting Scenes Inside a Sprite View
Animation and rendering is performed by an
SKView object. You place this view inside a window, then render content to it. Because it is a view, its contents can be combined with other views in the view hierarchy.
Content in your game is organized into scenes, which are represented by
SKScene objects. A scene holds sprites and other content to be rendered. A scene also implements per-frame logic and content processing. At any given time, the view presents one scene. As long as a scene is presented, its animation and per-frame logic are automatically executed.
To create a game or app using SpriteKit, you either subclasses the
SKScene class or create a scene delegate to perform major game-related tasks. For example, you might create separate scene classes to display a main menu, the gameplay screen, and content displayed after the game ends. You can easily use a single
SKView object in your window and switch between different scenes. When you switch scenes, you can use the
SKTransition class to animate between the two scenes.
A Node Tree Defines What Appears in a Scene
SKScene class is a descendant of the
SKNode class. When using SpriteKit, nodes are the fundamental building blocks for all content, with the scene object acting as the root node for a tree of node objects. The scene and its descendants determine which content is drawn and how it is rendered.
Each node’s position is specified in the coordinate system defined by its parent. A node also applies other properties to its content and the content of its descendants.

Always stay in control!
TexturePacker comes with a graphical user interface, showing you how your sprite sheets look.
Changes to parameters are visible in real-time preview, even memory optimization.
Create texture atlases directly from:
- Adobe Photoshop (.psd)
- Flash Movies (.swf)
or various other input formats.
Common questions for developers are:
How much disk space does the texture need?
With TexturePacker's GUI you always see the memory consumption and dimensions of the texture atlas.
TexturePacker creates a header file for you together with your atlas. You can simply import it using:
Using the defines in the header file, creating a sprite is a 1-liner:
SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithTexture:SPRITES_TEX_BACKGROUND];
This makes it extremely simple to animate sprites. Play your animation with:
SKAction *walk = [SKAction animateWithTextures:SPRITES_ANIM_CAPGUY_WALK timePerFrame:0.033]; [sprite runAction:walk];
With this you find missing sprites at compile time - not at runtime when your game is already in the AppStore.
- Check for missing sprites at compile time
- Increase code quality
- Easily handle animations
Focus on high resolution sprites only while creating your app for iPad, iPhone and iPad Mini. TexturePacker does all the scaling for you. No need to use an external tool to resize the images.
Using pre-scaled sprites keeps the frame rate high and reduces runtime memory consumption.
- Reduce memory consumption
- Increase performance
- No additional work required
Instead of adding and removing individual sprites TexturePacker allows you to simply add a complete asset folder. Every image that is found inside it will be added to the sprite sheet.
TexturePacker preserves your folder structure in the sprite names inside the data file allowing you to easily group your sprites.
TexturePacker detects all changes and automatically reads the new sprite data when re-entering the application or publishing from command line.
With the powerful command line interface you can simply update all sprite sheets at once.
You don't have to be a developer to use TexturePacker. It's easy right from the start.
Common questions for artists are:Do all sprites fit into a single atlas?
Simply add your sprite folders and see if they all fit. TexturePacker shows you the sprite atlas in real-time.
Maybe you need to drop some frames?
Or is there enough space left to make the animation even smoother?

Learn how to make iOS games using Apple’s built-in 2D game framework: Sprite Kit. Through a series of mini-games and challenges, you will go from beginner to advanced and learn everything you need to make your own game!
iOS Games by Tutorials covers the following topics:
- Sprites: Get started quickly and get your images onto your screen.
- Manual Movement: Move sprites manually with a crash course on 2D math.
- Actions: Learn how to move sprites the “easy way” using Sprite Kit actions.
- Scenes and Transitions: Make multiple screens in your app and move between them.
- Physics: Add realistic physics behavior into your games.
- Beyond Sprites: Add video nodes, core image filters, and custom shapes.
- Particle Systems: Add explosions, star fields, and other special effects.
- Adding “Juice”: Take your game from good to great by polishing it until it shines.
- Accelerometer: Learn how to control your game through tilting your device.
- UIKit: Combine the power of UIKit with the Sprite Kit framework.
- Mac: Learn how to port your games to the Mac!
- Tile Maps: Make games that use tile maps.
- Scrolling: Make levels that scroll across the screen.
- And much more, including: Fonts and text, saving and loading games, and six bonus downloadable chapters!
The iOS Tutorial Team takes pride in making sure each tutorial we write holds to the highest standards of quality. We want our tutorials to be well written, easy to follow, and fun. And we don’t want to just skim the surface of a subject – we want to really dig into it, so you can truly understand how it works and apply the knowledge directly in your own apps.
By the time you’re finished reading this book, you will have made 5 complete mini-games from scratch, from zombie action to space shooter to top-down racer!

You also decide which physics bodies can collide with each other and separately decide which interactions cause your app to be called. You use these callbacks to add game logic. For example, your game might destroy a node when its physics body is struck by another physics body.
You can also use the physics world to find physics bodies in the scene and to connect physical bodies together using a joint (
SKPhysics). Connected bodies are simulated together based on the kind of joint.
See Simulating Physics for more information.
Getting Started with SpriteKit
SpriteKit implements content as a hierarchical tree structure of nodes. A node tree consists of a scene node as the root node and other nodes that provide content. Each frame of a scene is processed and rendered to a view. The scene executes actions and simulates physics, both of which change the contents of the tree. Then the scene is rendered efficiently using SpriteKit.
To start learning SpriteKit, you should look at these classes in the following order, before moving on to other classes in the framework:
Creating Your First Scene
SpriteKit content is placed in a window, just like other visual content. SpriteKit content is rendered by the
SKView class. The content that an
SKView object renders is called a scene, which is an
SKScene object. Scenes participate in the responder chain and have other features that make them appropriate for games.
Because SpriteKit content is rendered by a view object, you can combine this view with other views in the view hierarchy. For example, you can use standard button controls and place them above your SpriteKit view. Or, you can add interactivity to sprites to implement your own buttons; the choice is up to you. Later in this example, you’ll see how to implement interactivity on the scene.
SKView can be added as a child to a
UIView, or you can explicitly cast your view controller’s view to to a SceneKit view either through storyboards, using Custom Class, or in code. The following listing shows how you can override a view controller’s
view method to cast its view to an
With the SpriteKit view created, the next step in displaying content is to create a scene.

For example, when a node is rotated, all of its descendants are rotated also. You can build a complex image using a tree of nodes and then rotate, scale, and blend the entire image by adjusting the topmost node’s properties.
SKNode class does not draw anything, but it applies its properties to its descendants. Each kind of drawable content is represented by a distinct subclass in SpriteKit. Some other node subclasses do not draw content of their own, but modify the behavior of their descendants. For example, you can use an
SKEffect object to apply a Core Image filter to an entire subtree in the scene. By precisely controlling the structure of the node tree, you determine the order in which nodes are rendered.
All node objects are responder objects, descending either from
NSResponder, so you can subclass any node class and create new classes that accept user input. The view class automatically extends the responder chain to include the scene’s node tree.
SKNode reference for more information.
Textures Hold Reusable Graphical Data
Textures, represented as
SKTexture objects, are shared images used to render sprites. Always use textures whenever you need to apply the same image to multiple sprites. Usually you create textures by loading image files stored in your app bundle. However, SpriteKit can also create textures for you at runtime from other sources, including Core Graphics images or even by rendering a node tree into a texture.
SpriteKit simplifies texture management by handling the lower-level code required to load textures and make them available to the graphics hardware. Texture management is automatically managed by SpriteKit. However, if your game uses a large number of images, you can improve its performance by taking control of parts of the process. Primarily, you do this by telling SpriteKit explicitly to load a texture.
A texture atlas is a group of related textures that are used together in your game. For example, you might use a texture atlas to store all of the textures needed to animate a character or all of the tiles needed to render the background of a gameplay level. SpriteKit uses texture atlases to improve rendering performance.
Nodes Execute Actions to Animate Content
A scene’s contents are animated using actions. Every action is an object, defined by the
SKAction class. You tell nodes to execute actions. Then, when the scene processes frames of animation, the actions are executed.

Create a new scene with a Position2D node named UIMenuSelectArrow as its root, a Sprite, an AnimationPlayer, and a Tween. Save it as
We’ll use the tween node to animate the arrow’s position. Simultaneously, the animation player will make the sprite wiggle, as you might’ve seen in games like older Final Fantasy titles. This way, both animations can play at the same time.
In the FileSystem dock, find
menu_selection_arrow.png and assign it to the sprite’s Texture property.
Place the sprite and its pivot so with a position of (0, 0), the arrow is to the left of the origin. To change the pivot’s position, select the sprite, place your mouse cursor where you want the pivot to be located, and press v.
With the AnimationPlayer, animate the sprite’s position going back and forth. To do so, you need two keys and to toggle the animation’s looping option. Also, set the animation to Autoplay on Load. In the image below, I’ve highlighted the icons corresponding to the two options.
On the first keyframe, I’ve pulled the easing curve to the left in the Inspector to give the motion some bounciness.
Attach a script to the UIMenuSelectArrow with the following code.
# Arrow to select actions in a [UIActionList]. extends Position2D onready var _tween: Tween = $Tween # The arrow needs to move indepedently from its parent. func _init() -> void: set_as_toplevel(true) # The UIActionList can use this function to move the arrow. func move_to(target: Vector2) -> void: # If it's already moving, we stop and re-create the tween. if _tween.is_active(): _tween.stop(self, "position") # To move the arrow, we tween its position, which is global, for 0.1 seconds. # This short duration makes the menu feel responsive. _tween.interpolate_property( self, "position", position, target, 0.1, Tween.TRANS_CUBIC, Tween.EASE_OUT ) _tween.start()
Next up is the action list scene. Create a new scene with a VBoxContainer named UIActionList as its root. Add an instance of the UISelectBattlerArrow scene as its child and save the scene. Attach a script to the root node.

Sprite Kit is Apple's development framework with an Open-GL based renderer for 2-D and 2.5-D game developers. According to Apple Insider, the framework's "built-in support for physics makes animations look real, and particle systems create essential game effects such as fire, explosions, and smoke." Previously, iOS developers were able to use third-party platforms for the same purposes. Now that Apple has created its own tool, it is capable of staying with and growing with Apple, rather than being acquired and taken in a different direction. Rybakov said, "Ninety percent of the purchased applications are games, which are 2-D games in more than half of the cases, and Apple cares about its game developers."

An efficient way to store 2D animation for games is to layout all the frames withing one texture called a ‘Sprite Sheet’ or ‘Texture Atlas’.
This saves resources by avoiding multiple texture loading operations and only animating the UVs of the shader to display the needed image at each frame.
Sprite Sheets are also used to pack various states of game graphics and textures for multiple objects in one file.
Sprite Sheets can be created manually using any image editing software,
For an automated process and more control, a specialized software like Texture Packer can be used.
And it can also be done automatically in Adobe Animate (Flash).
* There are many more solutions / scripts that will do that you can find on the web…

You want to use a spritesheet containing 2D animations.
Spritesheets are a common way for 2D animations to be distributed. In a spritesheet, all of the animation frames are packed into a single image.
For this demo, we’ll be using the excellent “Adventurer” sprite by Elthen. You can get this and lots of other great art athttps://elthen.itch.io/.
Make sure the images in your spritesheet are laid out in a constant-sized grid. This will enable Godot to automatically slice them. If they’re packed irregularly, you will not be able to use the following technique.
This animation technique uses a
Sprite2D node to display the texture, and then we animate the changing frames with
AnimationPlayer. This can work with any 2D node, but for this demo, we’ll use a
Add the following nodes to your scene:
Drag the spritesheet texture into the Texture property of the
Sprite2D. You’ll see the entire spritesheet displayed in the viewport. To slice it up into individual frames, expand the “Animation” section in the Inspector and set the Hframes to
13 and Vframes to
8. Hframes and Vframes are the number of horizontal and vertical frames in your spritesheet.
Try changing the Frame property to see the image change. This is the property we’ll be animating.
AnimationPlayer and click the “Animation” button followed by “New"
. Name the new animation “idle”. Set the animation length to
2 and click the “Loop” button so that our animation will repeat (see below).
With the scrubber at time
0, select the
Sprite2D node. Set its Animation/Frame to
0, then click the key icon next to the value.
If you try playing the animation, you’ll see it doesn’t appear to do anything. That’s because the last frame (12) looks the same as the first (0), but we’re not seeing any of the frames in-between (1-11). To fix this, change the “Update Mode” of the track from its default value of “Discrete” to “Continuous”. You can find this button at the end of the track on the right side.
Note that this will only work for spritesheets where the frames are already in order. If they are not, you’ll have to keyframe each Frame seperately along the timeline.

Animating Multiple Sequences
You will always have multiple animations for your characters. For example, an idle sequence, a run sequence, an action sequence, and so on. You need to work in a specific structure so you can export all of these animations to a single sprite sheet.
First, create a scene file with the name of the character, such as
Space Duck. This is the file where you can create or import your game rig. In the top menu, select File > Save As New Version, and give this new version the name of the animation. For example,
Every time you need to do a new animation using the same character, perform a Save As New Version. In the end, you may have something like this:
Scene: Space Duck
When you run the export script, it will export the drawings from the current scene into the export folder. It will also let you know if there are any other scene versions that were already exported to that folder. If so, then it will recompile the sprite sheet to include all the drawings from all the animations. This allows the maximum possible reuse of drawings.

Animations make content in your game move and come alive! You can use Animations to create moving platforms, disappearing enemies, or life like Story Blocks.
Animating enemies effect how the Character interacts with the object! If you animate a hazard block to be spikes popping up and down, the Character would be able to walk across the spikes when they're down without being hurt!
Adding animations to your game is simple! To add animations:
- Tap the Decorate Tab in the Game Editor
- In your library, select the Animations folder
- Tap which animation you wish to add to your game
- Tap the blocks that you would like the animation blocks to be placed
- The animation is now in your game!
Note: Animations cannot be used in Game Backgrounds or Room Backgrounds at this time.
For more help with Animations watch this tutorial video.

This chapter adds a significant new feature to your Java toolbox—the ability to load and draw animated sprites and apply that knowledge to an enhanced new sprite class. You will learn about the different ways to store a sprite animation and how to access a single frame in an animation strip, and you will see a new class called
AnimatedSprite with some serious new functionality that greatly extends the base
Here are the key topics we’ll cover in this chapter:
Sprite animation techniques
Drawing individual sprite frames
Keeping track of animation frames
Encapsulating sprite animation in a class
Over the years I have seen many techniques for sprite animation. Of the many algorithms and implementations ...

In the next context menu you will have options to trim exported layers of transparency, set the exported file format, only export visible layers, and set a prefix to exported files among multiple other options.
001 Game Creator also supports animation by way of manipulating the position and rotation (size and color/opacity too, for that matter) of multiple individual parts of a Sprite between key frames (including an interpolation feature which allows for smoother transitions from one frame to the next), thus, animating entire sheets with actions of a character does not become a necessity on the artist’s part.
The point of rotation of a bone is located in the center of the image, so to make a bone more easily manipulable/rotatable, the bone’s joint must be centered in the image file. See image below for reference:
The lower arm limb that is part of a Sprite comprising a whole arm. Notice how its edge is centered on the canvas.
Using that image along with the upper arm part we can sequence them like this:
Combining both the upper and lower arm keyframes together will result in a smooth animation where the software will interpolate frames.
NOTE: If “Transition smoothly between keyframes” was unchecked, then the arm would simply snap back and forth instantly between keyframes.
Rotation using a graphic when the bone utilizes the entire canvas (or is not properly centered) is still possible; however to achieve the above results, the developer will also have to alter its position in addition to its rotation for all frames in order to keep it in one place as it’s rotating (in the above example, altering the lower arm’s position as well was necessary because it is a child bone while the the upper arm is a parent bone).
The same image of an arm as shown above, except this one takes up the entire canvas, meaning its pivot point is now mid forearm as also indicated by the crosshair. In this scenario, the arm will spin around the pivot point instead of rotating from the joint.This approach is not recommended for animating something of that nature but would be ideal for things such as symmetrical effect graphics.
001 Game Creator allows users to set a render priority (or layer order) of individual animation layers within a Sprite.

Last year I had blogged about animating sprite using Kinetic JS.
Code in that post was part of a simple game I had created. So the code specific for animating sprite was explained in snippets. A reader of that post contacted me with a request to provide a complete example. So I created a small demo of sprite animation only. If you are interested, you can download it from here. This demo animates images in the sprite sheet at a fixed location, it does not move the image. So I thought it would be interesting to add motion to sprite images when they are animated.
First, take a look at the demo. Click on the Walk button to make the person walk. You can stop any time. If the person hits right side wall, then she falls, which is also simulated using sprite animation. I know the ‘walk’ does not look natural, but creating graphics is not my string point and this is the best I could manage.

I added some FX from Mercury (Particle Fx engine) to my character run animation and added a gun and bullets.
Someone asked me if the actions were hard coded. Well, no, it’s not. I’m using the timeline I created before to add a movement to the animation (for example translation interpolation with two points or more). Then I just put it in the player “Action Bank”.
In addition you may use the timeline to trigger events or do rotations (with interpolation). Actually, at first this action editor’s purpose was only to make a tool to animate skeletons (which means I could do a character only based on skeleton animations too), but it’s useful for simple animations too.
Someone else asked me if I’m going to make a mario or megaman like game… No, I think I wont’t. Right now I’m just using megaman’s sprites cause I have nothing else to do some testing. 😦
But still, my engine and editor should help to make any kind of 2D game (plateformer, R-Type like shooters or Zelda like action/adventure games). I did some design for a plateformer, that’s why I’m testing plateform tools. I hope it won’t be too bad.
I should add a simple enemy in one of the next videos.

So, what is the difference between your sprites if they all have the same behaviour?
Basically, the atributes...
Imagine my example: the "Monster" object have events for losing hp, destroy the object when hp <= 0, walk, run, flee, attack, etc.
All those elements should be the same for all monsters, considering it's speed, size, hp, strenght, image/animations, etc etc. You see?
The "solution" so far that i tought is to have a monster object, with all monsters i have on single frames and an array containing it's default attributes, indexed by monsters image frame.
So on frame 1 have a turtle? on arrayMonstersInfo i have turtle's data;
On frame 2 a dragon? arrayMonstersInfo contains dragon's data, etc etc.
The problem here would be only the animations =/

broken into bite-size chunks
Session 1 – Creating the Hero
- Series Introduction – 3:54
- Initial Setup – 13:09
- Adding the Hero Class – 16:32
- Moving the Hero – 16:22
- Gestures and Adding Animation – 20:32
- Adding Physics Properties to the Hero – 18:01
Session 2 – Building the Maze in an SKS or Tiled File
- Intro to Session 2 – 1:24
- Create a Maze Boundary using a Sprite Kit Scene (.sks file) – 26:08
- Adding the Physics Contact Delegate to the Game Scene – 12:09
- Introduction to using Tiled for Level Layout – 11:46
- Parsing the Tiled File (parsing XML in general) – 22:41
- Centering the Hero in the World – 10:29
- The Star Class (a sprite for the Hero to pickup) 17:48
- The Star Class Continued – 8:17
Session 3 – Sensors, Edges, and Enemies
- Intro to Session 3 – 1:31
- Adding Sensor Nodes around the Hero – 16:16
- Using the Sensors to Detect Walls – 13:29
- Adding an Edge Based Physics Body Around the World – 16:25
- Placing Enemies with either SKS or Tiled Files – 18:56
- Moving Enemies – 25:13
- Refining Enemy Logic for Tracking the Hero – 18:12
- Reloading the Level – 12:03
Session 4 – Property Lists,

The essence of the match-three game is to move fruits such that three fruits of the same type match up. This move is done with a swipe. The Game Scene is the best place for implementing the detection of the player’s swipes that will reposition the fruits into this match pattern. The reposition is called the swap. Recognizing these swipes to swap in SpriteKit is best done with the touchesBegan, touchesMoved, and touchesEnded functions.
Two optional properties that will aid in the computation required are swipeFromColumn and swipeFromRow. These properties will record the column and row number of the fruit that the player first touched when the swipe movement started. These are initialized to nil in the initializer init(size:).
In touchesBegan() we convert the touch location into either the column or row of the fruit touched by invoking a convertPoint() function that returns a tuple. convertPoint() ensures the CGPoint parameter passed is within the game grid otherwise it returns false. If the point is within the grid then we set the swipeFromColumn and swipeFromRow properties.
Detecting the swipe direction is achieved in the touchesMoved() function. In this function by comparing the new column and row numbers to the previous ones we determine whether the swipe direction is left, right, up, or down. Knowing the direction we then use the trySwap() function passing the horizontal and vertical deltas.
trySwap() is the workhorse of the swipe to swap functions because at this point we only know the direction the player swiped but we need to determine if there are two valid fruits to swap in that direction. We make this determination by calculating the column and row numbers of the fruits to swap with. Eliminating the edge swipes off the board and determining whether there is actually a fruit at the new position ensures that we implement a valid swap. For today I just have a print() of the from Fruit and to Fruit in order to see if this is all working.
Tomorrow, I’ll animate these swipes to swap.

2D Animation Tutorial Using Spine for Mobile Apps
In the classic book by Disney animators Frank Thomas and Ollie Johnson, “The Illusion of Life”, the art of character animation is described as crafting,
“drawings that appear to think and make decisions and act of their own volition.”
Animation, especially of living things, seems like a major hurdle for the mobile app developer who needs to create people, insects, birds, and lifelike plants to bring their mobile games to life. Many turn to sprite sheets, using software such as Texture Packer to turn a series of drawings into a ‘moving picture’ much like the Disney animators did, frame by frame with each sprite moving slightly to give an illusion of a moving figure when played in sequence, like an old-fashioned flip book.
Sprite sheets, however, present some problems for mobile apps if they are at all complicated. First, they are difficult to edit and maintain, as to change any element of the sprite sheet means precisely replacing all elements of a sprite sheet. One mistake and the animation looks jerky and “unreal”.
Additionally, sprite sheets consume a certain amount of texture memory in your app. First, you will need a copy of each element of your animation embedded into your sprite sheet, there might be dozens of images packed into a .png file. Second, you might want to content-scale that sprite sheet so that it looks good on retina screens, so you will need a @2x version of it, using even more memory. For fast-moving games with many complex animations, sprite sheets can quickly become a maintenance and memory problem.
There must be a better way!
Enter Spine, the easy-to-use and well-designed software by Esoteric Software. Spine was created as a Kickstarter project and has quickly become a tool of choice for many developers of mobile games. As one Corona developer noted,
“…bought it after trying it for something like 2 seconds.. This is the coolest thing that happened for Corona based games since Corona!”
Instead of creating frame-by-frame animations, Spine works by creating skeletal animations. In short, you create a skeleton and “dress it” into a skin, apply keyframes, and create an animation in a short amount of time. It’s an intuitive process once you understand the basics of the software.

This describes how game assets are created, which involves serious amount of scripting and automation
This is sub-layout for documentation pages
Asset creation can be one of the most time consuming things in entire game development.
If it can be automated, it saves unbelieveable amount of time.
The point of asset automation is not short running speed, but to require as less human effort as possible
This focuses on how the graphics for the game is created.
Each character must have separate texture sheet for all angles of the animation. Here is an example of walk animation, for right and upper-left angle:
Even if we use blender, we would have to rotate model, and then click to render.
Then repeat this process to render all frames.
This, however, can be automated by running a custom made python script, which rotates the model base by constant angle, and then renders, and repeats, until all angles have been rendered
Now, after blender rendering, we are left with like 200 files, and they all have alot of transparent pixels around.
From this, we want to create spritesheet, one for each angle.
For this puspose, I have written an application using C Sharp language, that helps to create the spritesheets with only few clicks
The following algorithm is implemented in the application mentioned above, and allows complete automation of spritesheet creation,
aswell as the animation JSON, containing the animation data.
Input: X files, where each file is one frame of animation. They go in order, first, only frames for R angle, then for RD angle, and so on. (that is defined by the blender python script)
Output: A minified sprite sheet + .JSON file for each angle. JSON file contains animation data
Imagine following two sprite frames. Since all frames do have same size, we
can cut off the transparent pixels in such a way to minimize final image size
Note: although the images look identical, they are not, they differ only slightly, since they form an animation...
After minification we would get final spritesheet like this:
As can be seen, the transparent pixels were removed to minify the final spriteshet
The approach to achieve this is as follows:
Allthough the technique above allows serious automation of really any animation desired,
it is not enough, and unfortunatelly, for certain animation sheets,
an origin point must be defined in order to achieve correct displayment.
Let's simplify the problem to only one frame per animation.

Continue reading
In order to provide a visual cue to the player the selected swiped fruit should be highlighted momentarily in order to indicate which fruit the player is about to swap. This selection highlighting animation can be achieved by temporarily placing a highlighted version of the sprite on top of the current sprite and having it along for the ride in the swap animation and eventually fading out. Continue reading
Having completed the swipe to swap it was time to update the model and animate the swap. This involved creating a new Swap struct. In Swift the struct is a value type versus a class which is a reference type. Here it makes sense to use a struct since the swap is inert and only stores data. The logic of handling the swap is not done by the swap itself. The detection of the swap is handled in the Game Scene and the real game logic is in the Game View Controller. Continue reading
The essence of the match-three game is to move fruits such that three fruits of the same type match up. This move is done with a swipe. The Game Scene is the best place for implementing the detection of the player’s swipes that will reposition the fruits into this match pattern. The reposition is called the swap. Recognizing these swipes to swap in SpriteKit is best done with the touchesBegan, touchesMoved, and touchesEnded functions. Continue reading

Then theres something I don't understand. (an experience not wholly unfamiliar to me) How/when can you rotate using the SpriteEngine? Back when I brought this up last time you said something about just having different animations for it. Not what I'm looking for, but you seem to be hinting at what I want now.
If you had a dollar for everytime I asked a question, I know. Indulge me one more time please.
All my sprites are going to be top-down little buggers and need to face the direction they are looking in. This should be changing almost every single frame for most of the sprites, unless I design a boring combat system.
edit: added a LSL3 reference

At 3:00 they discuss that there is a method used to separate the parts of character into individual sprites and move them saving production time and video memory. What is this method called I am thinking that I want to implement it for my game but need to do more research. Thanks alot =)
It's called 2D skeletal animation. Essentially you're animating a skeleton that has sprites for the body parts placed on top of it. This allows you to reuse animations for different characters and characters can have multiple sets of armor, weapons, etc.
There are a number of questions on the site already about it:
And some other good resources:
Enjoy your research.

The Skinned Model sample from the App Hub education catalogue is great for getting animated characters into your game, but there’s a bit of a flaw with the export process. The problem is, when you export your character from 3DS Max (and possibly other modelling programs), all you get is one animation, named ‘Take 001’. Wouldn’t it be nice if we could define different animations for different parts of the animation timeline? Well, we’re going to do just that :). As an added bonus, we’ll also be adding in events, so you can be notified when certain parts of your animation are hit.

| The Kwik PhotoshopR plugin can be used to create interactive mobile apps. One way to create an animation in Kwik is the sprite sheet. Kwik comes with its own sprite sheet script which we will use for this tutorial.|
For the finished animation that we will create from the sprite sheet, I will use my Fred the Frog character. In the original file, Fred is on the top layer and his left arm and hand are on the bottom layer. We will animate his left arm to wave.
The kwik sprite sheet script creates a sprite sheet from the layers in the Layers panel. Each layer is a different frame for our animation. Therefore, each layer will have Fred in the same position but with his arm moved left or right slightly.
Let's build the layers for the animation.

As the name suggests, the animation will be on a per-bone basis, where each body bone can have a specific action or animation. Having all the main body parts of the character separated allows the developers to create the animations directly in the engine. This new animation technique is very similar to what is used in 3D animation.
In this tutorial, we're going to focus on bone-based animation. However, note that Unity does not do true bone-based animation, so we will simulate it.
Preparing The Sprite For Animation
Drag the sprite file to the editor and drop it on the Sprites folder, like so:
Before any character is ready for animation, you need to add a
Scene to the project. Create a
Scenes folder in your Assets directory, then create a new scene and save it as
Test.scene within this folder. At the end of this step, you should have something like this:
Now, still in the Project tab, select the
dragon sprite, then look at the Inspector panel:
As you can see in the Sprite Mode property in the Inspector, the Sprite Mode is set to Single. This means that the engine will use the entire texture as a whole when creating a new sprite. Since we have the body parts separated in the
dragon, we don't want that to happen. We therefore need to change the Sprite Mode from Single to Multiple.
When you change the option, a new button labelled Sprite Editor appears:
Currently, the Sprite Editor slicing tool does not work well on compressed images. In order to ensure the best result for the animated sprites, you need to change the Format value on the bottom of the Inspector tab from the default option, Compressed, to Truecolor. Then, click Apply.
Now, select the dragon sprite and click the Sprite Editor button. A new window will pop up:
In the upper left corner of the window, you will find the Slice button. Click on it, and another menu will pop up:
This menu allows you to change the parameters of how the sprite will be sliced by the engine. If you set the slices to Automatic, the engine will try to detect the different parts of the character you have in the image. You can define a minimum size for the slices, a pivot (the point around which the slice rotates) and one of three methods:
- Delete Existing will replace any existing slices.
- Smart will try to create new slices while retaining or adjusting the existing ones.

The SpriteKit Scene editor lacks some of the workflow benefits of Tiled. For example, snapping to a grid or selecting and copying objects as a group can be a bit tricky.
Children created within the scene editor are limited to SKNodes, SKSpriteNodes, SKShapeNodes and some other physics field types. This means to make use of our custom classes, like Hero, Enemy, Boundary, you’ll learn how to find children in the scene editor and replace them (by name) with our classes. Which is essentially what we’ll be doing when parsing Tiled files. So although the tutorial teaches both layout options, there is a lot of overlap in the code.
Every student graduates with a mighty parting gift!
Like all our tutorials, you get the finished Xcode project from the course, as well as the project files from the end of each session (updated for Swift 1.2). The finished project contains an enormous amount of source code portable to any of your apps in the future.
After your purchase, you’ll always have the code to…
- Import a Tiled file into a Swift / Sprite Kit based project
- Parse any XML data into a Swift / Sprite Kit based project
- Play audio, either through an SKAction or AVAudioPlayer
- Setup swipe gestures in an SKView
- Pull children from a Sprite Kit Scene file and replace them with custom classes
- Setup a SKPhysicsContactDelegate and listen for bodies contacting each other
- Center a Sprite Kit world around a specific child
- And much, much more!
Two affordable purchasing options…
Purchase Option 2 - Subscription Access
Both Monthly and Yearly Subscribers can stream every video tutorial on the site. Yearly subscribers get access to the latest version of every starter kit whenever they want, plus access to hundreds of dollars worth of royalty free game art (yes, it’s an amazing deal). You can cancel your Monthly or Yearly subscription anytime directly through Paypal.Browse All Courses
Already a Subscriber? Get started on the course from right here.

- Color Layer
In any Cocos2D node that is currently added to a scene, you may schedule and unschedule events. For my animation, I created a separate attack overlay layer that holds the animation, and sits above the game layer. As such, I could schedule and unschedule events right into the layer to control it.
Looking at the flash animation, you can see that there are several steps that must be followed:
1) Attacking unit slides in
2) Attacking unit name appears above it
3) Defending unit slides in
4) Defending unit name appears above it
5) Units able to attack pull back
6) Units able to attack charge at enemy unit
7) An animation/effect plays in front of attack unit
8) Screen shakes and flashes
9) Dead units fly off the screen
10) Surviving units grow and fade out
If I were to rough this out in my layer, I might have code that looks something like this:
if((self = [super init]))
//Store any parameters, create objects, etc.
-(void) slideInAttackingUnit:(ccTime) elapsedTime
//Do slide code
[self schedule:@selector(attackingUnitNameAppears:) interval:0.5f];
When Cocos2D schedules an event on a node, it will call that event whenever the interval passes. (If no interval is supplied, it will instead call that event every frame). In the case of this animation, we only want each event to happen once, so we unschedule the current method as soon as it is entered and then schedule the following one.
I'm sure that the scheduler is familiar to most Cocos2D developers so I'll move on to the next section.
If you pay close attention to the flash animation, you will see that there is actually a very short white flash when the units collide. You will also notice that there is a bit of a blueish overlay when it first starts running. Both of these can easily be accomplished using a CCColorLayer.
Placing a Color Layer is incredibly simple; you simply initialise it with the colour you want it to be, and add it to your scene, as below:
CCColorLayer *backgroundLayer = [[CCColorLayer alloc] initWithColor:ccc4(128, 128, 255, 100)];
I typically use alloc/init instead of the convenience methods where available, just to have a little more control over memory.

It's a stylistic choice and except in very tight memory situations, not entirely necessary. By setting the alpha to something less than a full GLByte of 255, it can function is a nice barrier between your current layer and what's behind.
For the white flash, using a ColorLayer in conjunction with the scheduler is quite effective. Consider the following:
flashLayer = [[CCColorLayer alloc] initWithColor:ccc4(255, 255, 255, 255)]; //flashLayer is an instance variable
[self schedule:@selector(removeFlash:) interval:0.05f];
-(void) removeFlash:(ccTime) elapsedTime
flashLayer = nil; //will be removed from memory - we don't want dangling pointers!
This simply adds and removes a white color layer very quickly to simulate a flash. Simple!
Cocos2D comes with a variety of actions. Ignoring animations, the ones I find myself using most are CCMoveTo/By, CCScaleTo/By, CCRotateTo/By, and CCFadeIn/Out.
The difference in the transform actions, for example CCMoveTo/By, is absolute versus relative. CCMoveTo moves an object to an absolute position; CCMoveBy to a relative position. For those who don't know what that means, the names help make sense of it, but here's a quick example: Imagine that you have an object at position 200, 200. If You were to apply CCMoveTo(100, 100) to it, it would move to 100, 100. Whereas, if you were to apply CCMoveBy(100, 100) to it, it would move to 300, 300.

Canvas Components, Controls and more!
SpriteSheets let you animate graphics by loading one graphic and providing data for the frames. CreateJS has SpriteSheet and Sprite support. ZIM uses these as a base and then adds a couple extra features.
The example mimics a PhaserJS tutorial but the ZIM example is 63% of the size. Also ZIM uses the power of zim.animate() to play the Sprite – with the run() method. This allows you to:
Here is a video Tutorial: https://youtu.be/WWEms6qy9KA. You can also play labelled animations. CreateJS Sprite and SpriteSheet support even more operations but these have not been brought in to the run() method. You can still use the CreateJS play(), gotoAndPlay(), gotoAndStop() methods with a ZIM Sprite, but you may be limited to one frame rate.
We also have found that for teaching Sprites, there are a lot of Sprite sheets out there without data – or with data that is not made for CreateJS. A ZIM Sprite can easily read create SpriteSheet data for these spritesheets as long as the frames are the same size. See the ZIM Sprite Docs for more information.
Here is a new version of the TexturePacker CapGuy on a Skateboard! This features the animation series technique new to zim.animate() – but now also available on the run() method of the Sprite. This allows pausing and stopping by ID – including using the id with zim.animate() and move() animations. It also allows for a sequenced series of labels or frame numbers to be played in conjunction with the traditional transformation properties, etc. such as scale, rotation, skew, position, etc.
See this post on a DYNAMO – which is a Dynamic Sprite – so a Sprite that can change speed depending on mouse or key input for instance! This can be operated by an Accellerator which can increase or decrease the whole scene including Sprites and Scrollers.

All the photographs will also be discovered in the Images.xcassets listing. Concerning the Bird animation and the bonus animation, the sprites are stored on other directories (Bird.atlas, BirdLifeless.atlas, powerup1.atlas): merely change the frames of each and every animation with yours. Do the identical for song and sounds: merely change the sound information with yours. To set up all the settings for the sport (in order to switch the gameplay) you could have a devoted magnificence (Settings.swift). Everything is easily commented in the code, so it’s in reality simple to grasp the whole thing. If you could have any issues, you’ll learn the detailed pdf with all the directions, or question me for info, I can be more than pleased that can assist you.

Author: Mark Suter
- Working with the built in sprite editor to create and edit sprites
- Creating animations with the built in sprite editor
- Modifying the animation properties
- Editing image properties including resizing images, creating transparent images, etc.
In this tutorial you will learn to use the sprite editor including the drawing tools, setting transparency (get rid of that ugly white box around your character!), making multiple enemies out of one original, and animation tricks (adjust speed, size, rotation, etc) (9:21)

I need help with workflow suggestions for a flash game. (although the concepts would apply to other game engines, too).
In a game like: Hero Academy
There are several different character models each with a multiplicity of animations (walking, standing, getting hurt, attacking, etc.). I am certain that each of these could be manually animated and a sprite sheet generated and used, but when you add up how many animations and core drawings would be needed...that would be near insanity to complete.
So, in research I found that some are creating character models in Blender, Maya, a 3d engine of some kind - setting the camera angle to 45deg, etc. animating and exporting that sprite.
In each of these examples however, the character models were 3d looking i.e.: 3d to 2d
When I look at Hero Academy, they still look like a 2d drawing.
If I am looking to re-create a similar art style to Hero Academy and need several animations per model what is the most efficient/correct workflow to creating the animation? Manually creating each animation sprite in Flash? Or utilizing 3d and texturing it to look 2d?(if that is even possible)?
EDIT: Thank you to all those who have posted great answers. To add information to the concept, one 'issue' I am contending with is the modeling/view of our desired game. To further clarify, if you look at Hero Academy's grid system (a la chess board) if you wanted an entity to be able to move vertically or diagonally this would need it's own sprites. However, is this still a simple 2d side scrolling game since the camera is fixed? And they have simply designed the background map to have the EFFECT of perspective?
If that is the case, then using Nuoji's comments, a 2d skeleton would then again be possible.
The base question is: if we are looking at close to 100 different character entities all with their own movement animation, long and close range attack animations, taunts, etc. what is the most expeditious method of doing this?
Note that I have experience in programming but no design/modeling experience. Whether we went the flash animation route or 3d modeling route I would be learning from scratch so any previous skill or preference is nullified.

Couple of weeks back we published an article which introduced the wonderful world of iPhone programming. This article takes a step further and explains how to create animation using the image sequences.
Downloading Image Sequences:
This article is based on the CampFire iPhone application demo published on http://www.appsamuck.com website. You can download the complete code and the images used in the article using the link provided on their website
Creating Campfire Application:
Open XCode and start a new project. Select View based application from the project templates. Name your application "Campfire", this will create appropriate files using the application name. Open xib file and drag a UIImageView on the screen. The UIImageView control is used to display images on the iPhone screen.
Next, open the CampfireViewController.h file and implement the following code:
The CampfireViewController declares the UIImageView control and expose it using the "imageView" property. The implementation file is shown below:
The viewDidLoad is fired when the View is loaded successfully. The imageView.animationImages is a NSArray which contains the information about the images. The images are kept in the NSArray in the form of UIImage instance. UIImage is used to display image. The imageNamed property of the UIImage class is mapped to the image names. The animationDuration represents the total time the animation will run. The animationRepeatCount is assigned zero which means the animation will run continuously. Finally, we call the startAnimation method to start the animation. The animation shows the fire and since it is looping through the images very quickly it seems like a movie is being played on the iPhone.
In the implementation above we have hard-coded the images. This is reasonable if you have 10-20 images but as soon as you have hundreds of images this technique will become a big headache. In the next section we will demonstrate how to fetch the images from the resources folder an perform the animation.
Fetching Images from Folder:
First, create a new folder called "BonFireImages" under the Resources folder and place all the images in it. The code below shows how to fetch images from the "BonFireImages" folder and then start the animation.
The NSBundle is used to locate different resources in the project structure. The pathsForResourcesOfType method is used to fetch the resources of type "gif" contained in the "BonFireImages" folder.

Also you can see that I used the x and y variables of the object to place the image at the desired location, and also used image and height variables which are available in any display object.
In case you are not familiar with the arc4random() function it is a function used to generate random numbers (supposedly providing a greater degree of randomization than the rand() function), and does not need to be seeded.
Now we’re going to send the balloon upwards, and there are two ways to do that one way would be to modify the x and y coordinates of the balloon image directly, but we’ll take the easy way out and use the SPTween class.
time:(double)((arc4random() % 5) + 2)
Notice that I supplied the SPTween class with the image file, how long I wanted the animation to last for (in seconds) and a transition. There are many different transitions available (which can be found in the SPTransitions.h file included with the Sparrow Framework) the linear transition is simply an animation which is done with completely linear timing from start to finish.
Now we’re going to create the actual animation by changing a couple of properties.
[tween animateProperty:@"y" targetValue:-image.height];
All we had to do was change the x and y properties of the image, and the Sparrow Framework modifies these properties over the duration we specified as time when we created the Tween. If you’d like to see the properties available for an image you can check the SPDisplayObject.h file.
Finally we will add this tween to the “juggler”.
The juggler handles the timing for all animations, and is associated with the stage the image we are animating is on.
Now to add a balloon to the stage we are going to add a call to the drawBalloon method at the bottom of the if statement in the initWitWidth method.
You should now see a single balloon rise through the top of the screen when you run the code like in this screenshot:
If you have any trouble you can download a project to bring you up to this point here.
In the next part of this tutorial we are going to make it so that when this balloon is touched it immediately falls through the bottom of the screen.
Submit A Resource
Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?
You can submit the url here.

The sequence of removing and re-adding behaviors, in combination with the Push’s
active property is very important to make things work together.
Now that you know the mechanics of UIKit Dynamics I strongly recommend to check the API documentation here and have fun creating crazy animations in your next apps!

What is the best way to run AI in Cocos2d?
I already have my AI implementations. Normally I would execute AI in my game loop by checking how much time has elapsed since last AI execution and whether I can execute it in the current situation, then finally execute it.
From my understanding, Cocos2d removes the concept of the GameLoop and replaces it with Actions, which is great, but I'm not sure how best to employ them to take over in this AI execution. My current workaround is to create a ccSequence that 1) Executes AI, 2) Executes another ccSequence that does the same thing (essentially make an Action loop). What I don't like about this is that Actions all have to be timing needs to be precise in Actions... but I can work with that.
Another thing I don't like is that while this is good for AI... what about rendering actions. I can easily render the result of my Action for me, but what about the result of another AI's action? Such as another AI killed me. I have to wait for my Action Sequence to execute before I can check if anything happened to me, but what if my action was 10 seconds long... do I stand there before I realise I should be dead?
I'm thinking now that I could have multiple Action sequences set up. One for my AI. One for general updates to me. But before I go too far down this path, are Action Sequences really a good replacement for ye olde Update methods?

Typically, you would subclass
SKScene for each scene you require, but simplicity, the following code simply instantiates a new scene object that is presented by the view:
To display content in SpriteKit, the relevant node is added to the scene, or a child of the scene. The final step in this example to display a label is to create an
SKLabel and add it to the scene:

The figure selector window, showing the default figure and sprite (image) figures.
13 13 Animation Frame Controls An animation can be created by creating a series of frames, where each frame differs slightly from the previous. After moving and editing your figures from their previous positions, click the 'Add Frame' button to add it to the time-line. The underlined A means that the 'A' keyboard key can be used as a shortcut/hotkey. The keyboard spacebar can also be used as a shortcut. The time-line, showing a selected frame and the right-click popup menu The time-line shows all the frames in the animation at the top of the main window. The scroll bar underneath the frames can be used to view any part of the animation if the number of frames exceeds the width of the window. The position of the time-line can be moved in one frame increments by clicking the arrows at either end of the time-line or using the keyboard arrow keys when the scroll bar has focus. The area to the left of the time-line frames shows the number of the frame being edited or added and the repeat number. Repeat: The value entered in the Repeat edit box determines how many times the frame should be repeated when played. This can be used to create pauses in the animation without having to create identical consecutive frames. Editing Frames Frames in the time-line can be edited by clicking on them. The main editing area will then show the edited frame. After editing the frame the changes can be stored by clicking the 'Add Frame' button or by selecting another frame in the time-line to edit. If you edit a frame and do not want to keep the changes, then you can discard the changes by clicking the same frame in the time-line that was being edited (this action cannot be undone). The < and > keyboard keys can be used to step the frame being edited left or right from the current frame being edited. This is equivalent to clicking a frame to the left or right of the current frame being edited and can therefore be combined with the Ctrl and Shift keys to select multiple frames, as described below.
14 14 Selected Frame Controls Frames can be selected by clicking on them in the same way as editing a frame. Selected frames are displayed with a blue border. Multiple frames can be selected by using the Ctrl or Shift keys in the same way as selecting multiple files in Windows Explorer.

The change of an object itself happens like a single-frame animation by displaying single frames one after the other. With the help of the key scenes, however, you can now specify how and where these individual images should be drawn. An example illustrates this.
You can create a single-frame animation to set the individual arm and leg positions of a moving person. You can then use this animated person in two key scenes in different positions. When creating the overall result, the individual intermediate positions are calculated automatically.
At each intermediate position, the following picture of the animated person is drawn. When an image cycle of the animated person has been completed, playback starts from the beginning.
You therefore need to draw a lot less images for the more complex single-image animation, because repetitive motion sequences are used multiple times.
In a keyframe animation any number of animated objects can occur. It is even possible to use a keyframe animation in another keyframe animation. Animation packages like Flash allow you to nest animations as deep as you like.
For some movements, the use of keyframes is too inaccurate, as the following example demonstrates:
Ball over corner
The ball moves rigidly to the defined key positions. In the real world, however, he would follow a gentler, curved path. These requirements are met by the technique of path animation.
You can draw a motion path for an object along which the object should move. For drawing the movement path, you can use stretch trains, gentle curves or freehand tools.
Another property of the path animation is that objects can not only move along the path, but can also orient themselves to it. This means that an object is still rotating during the movement. The gradient of the curve serves as a rotation angle for the animated object.
In this form of animation, one starts from a single image scene and specifies in a linear list actions, how this scene should arise and/or change.
The best-known example is probably the custom animation in PowerPoint. In this presentation software to design individual slides with graphic objects, such. E.g., texts, diagrams or pictures.
Animation lists determine how and when the individual graphic objects appear, change or disappear. Each individual action describes exactly one animation sequence, eg B. the flying in of an image or the color change of a frame. The animation duration is set as the property of the action.
The exact animation flow can be controlled to a limited extent.

Animations on iOS
paul at livecode.org
Mon Dec 14 16:15:21 EST 2015
I think it was Scott Rossi that figured out a way to play an animation by storing images as text in custom properties, then load each image in turn into an image object.
I would imagine this may be limited to smaller less complex animations, but up until now I hadn’t tried it myself, so I had a go…
Haven’t tested on mobile though, my LC & Xcode versions are out of sync again.
> On Dec 14, 2015, at 11:23 AM, Ben Rubinstein <benr_mc at cogapp.com> wrote:
> What are my options for displaying an animation in a portion of the card/screen on iOS?
> Currently I've tried:
> 1) making it into a video, in a very limited range of formats, and playing it from an external file using a native control
> Pros: works, choice of controller etc, plays from a separate file and starts up fairly quickly
> Cons: video formats not super-efficient for animation, and at least as I've managed so far, limited to certain resolutions - I'm forced to crop or squash my original animation.
> 2) making it into a GIF on the card, which works quite nicely except that there's an enormous delay going to the card, presumably as the animation is buffered.
> Pros: can be exactly the size I want; plays quite smoothly
> Cons: I've not managed to play this from an external file, and if it's embedded on the card there's an unacceptable delay.
> Is there a third way? Should I be able to set the filename of an image object to an external gif file? Are there some video formats accepted on iOS which are good for animation and which will allow arbitrary dimensions?
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the Use-livecode

Tween: (or Tweening) is short for in-betweening, the process of generating intermediate frames between two keyframes. This gives the appearance that the first keyframe evolves smoothly into the second keyframe, providing a seamless view of motion or value change.
Tweens are the backbone of your Animatron project - by creating and combining different tweens, you are designing the animation and determining the ways that the objects in your project interact with each other on the canvas.
The four types of tweens in Animatron are:
- Translate - changes in an object's position on the canvas.
- Rotate - changes in an object's angle.
- Scale - changes in an object's size.
- Opacity - changes in an object's transparency.
Here's a simple project that uses all four tweens. We'll start with an image of the Animatron Hero (our company mascot) placed slightly outside of the canvas. Note that we're in Animation mode and the playhead is set to 0 on the timeline ...
Then we'll set the playhead to 2.5 seconds and drag the Hero to a new location on the canvas, so it'll appear to fly into the frame from off-screen. A translate tween (shown in yellow) appears on the timeline, with black keyframes marking the beginning and end points in time of the movement.
Next, we'll rotate the Hero 720 degrees. The rotate tween appears in green below the translate tween we created earlier - the Hero will rotate 720 degrees between 2.5 and 3 seconds.
We'll also add a scale tween between 2.5 and 3 seconds, so the Hero grows larger during this time.
Then we'll add another translate tween to move the Hero to the bottom of the screen between 3 and 3.5 seconds - the pause in the translate tween is shown by the grey space, which indicates a static tween.
Finally, we'll move the playhead to 5 seconds and lower the opacity to 0%. Now we have an opacity tween shown in pink - the Hero will change from 100% opacity to 0% opacity between 3 and 5 seconds.

It is often useful to sequence many actions together to save code; for example, in order to give the unit portriats a bit of a jump back, I use the following code:
leftSprite.position = ccp(-leftSprite.contentSize.width / 2,
leftSprite.contentSize.height / 2);
CCDelayTime *delay = [CCDelayTime actionWithDuration:leftDelay];
CCMoveTo *move1 = [CCMoveTo actionWithDuration:0.23f position:ccp(leftSprite.contentSize.width / 2, leftSprite.contentSize.height / 2)];
CCMoveTo *move2 = [CCMoveTo actionWithDuration:0.02f position:ccp(leftSprite.contentSize.width / 2 - 5, leftSprite.contentSize.height / 2)];
[leftSprite runAction:[CCSequence actions:delay, move1, move2, nil]];
(leftDelay is a value I use to control which of the sprites appears first).
Take note of two things; first, the CCDelayTime at the beginning. This is useful if you want to add a delay to your animation. Next, check out the CCSequence; this allows you to string a bunch of actions together, and they will then happen one after another. CCDelayTime is pretty much only useful when used in conjunction with CCSequence, as it literally does nothing. When you have listed all of your objects, you must ad nil (the sentinel) so that the action knows to expect no more. If you don't do so, you will get the warning, "Missing sentinel in function call".

Just drag a sprite on to the black dot sprite within the Hierarchy to group it under the black dot.
On the next image you can see how the sprite hierarchy should look like after you have grouped the game objects.
Before moving on, rename your base game object to
Dragon. When you move the
Dragon game object, you can now move all the parts of the character on the scene.
But what if you want to move just one single sprite? For instance, if you want to move just the hand, you know that the arm is connected to the hand, so, if you move it, all the hand should move too, correct? If you try to do this, you will see that is not the case. When you select the arm and move it, the remaining parts of the body stay still. So, in order to move the complete body part, you need to create a hierarchy inside your sprite.
To make this process more intuitive, rename the body parts (by right-clicking and selecting Rename) with their respective names, like so:
Regarding the hierarchy, think of the character as a tree, with roots, a trunk, and branches. The black dot acts like the root of the tree; when you move it, all the character body moves. After the root comes the trunk; in this case, your trunk will be the body of the character, so this will be the next sprite in the hierarchy. All the other body parts are branches of the tree. However, you can still have branches of branches like, for example, in the tail—the
Tail Tip is a branch of the
Tail, and so on..
Organize the sprites of your character following this hierarchy:
Now, if you move the upper arm, all the parts of the arm will follow. Great, isn't it?
Re-Ordering the Sprites
Before you can start animating the character, there is still one last detail we need to take care of. As we discussed, the sprite parts are not being drawn in the correct order. To solve this, you must change the value of the Order in Layer parameter for each individual sprite.

When I need to use my high-level behavior, I am just going to actually add alloc init that new behavior and add it to my animator.
[ Pause ]
So something which is useful when you're building your own behavior is to think in terms of API.
What is the API you want to define on such an interaction behavior?
It could be something really simple like initWithItems, like what we did just a minute ago, and we'll see another example in this session when you can actually define a more complex API.
It's useful to think about how that is going to integrate with your existing application flow, like if you already have a gesture, it's always a good thing to match the ending gesture velocity with the system you're creating in dynamics.
And if you need that, it's not always the case, but if you need that, you can define per step actions.
It's just a block, you can define on UIDynamicBehavior and we're going to invoke that block with each simulation step.
So that's interesting when you want to, for instance, change the force based on an item position, to implement magnets for instance.
Of course, because we are running that with each simulation pick, you have to be careful about what we do what you do in this block.
There is one catch about combining behaviors, it's this UIDynamicItemBehavior class you can use to setup properties to your items.
With UIDynamicItemBehavior, you can change density, damping, you can block rotation, you can change friction or elasticity, and I was using that in my previous demo.
And there is no problem about combining many UIDynamicItemBehavior, especially if you are using if you're configuring distinct properties in each, because that's not going to conflict, right?
If you do want to change the same property in different UIDynamicItemBehavior, that's still possible, but we have to decide which one we pick.
And the last one wins.
We actually have quite a precise definition of what the last one is.
It's a pre-order depth first walk of the behavior tree.
Get it? Let's check that rule on an example, right?
So here is my behavior tree.
I have a few behaviors I don't care about and three UIDynamicItemBehaviors configuring elasticity and friction, but the question is what are the actual venues in my dynamic item?
So let's walk the behavior tree.
We start with default.
So first behavior is not a dynamic item behavior, so we don't care.

Loading In The Balloon Textures And Creating Upward Animation
The first thing we are going to do is load in the balloon png files. We’ll add an array variable to the game interface file (Game.h) as we will want to access the balloons from other places within the class.
We’re also going to add in a Sparrow sprite, sprites are display object containers, and we will use this sprite to hold the balloon images so that we can easily stop and reset the game.
Now we’ll head back to the game implementation file and load the textures into the array.
[balloonTextures addObject:[SPTexture textureWithContentsOfFile:@"bluetutorial.png"]];
[balloonTextures addObject:[SPTexture textureWithContentsOfFile:@"greentutorial.png"]];
[balloonTextures addObject:[SPTexture textureWithContentsOfFile:@"indigotutorial.png"]];
[balloonTextures addObject:[SPTexture textureWithContentsOfFile:@"orangetutorial.png"]];
[balloonTextures addObject:[SPTexture textureWithContentsOfFile:@"redtutorial.png"]];
[balloonTextures addObject:[SPTexture textureWithContentsOfFile:@"violettutorial.png"]];
[balloonTextures addObject:[SPTexture textureWithContentsOfFile:@"yellowtutorial.png"]];
Now the reason why i loaded these balloons as SPTexture objects rather than SPImage objects is because I will be using these textures to create images throughout the class, and rather than loading them in each time I can use the texture objects to quickly create images (you’ll see this in a moment).
Now let’s create the sprite for our playing field and add that sprite to the stage.
This sprite will hold the balloons, and content used to reset the game so that we can easily clear the screen and stop animations.
Now we’re going to create a new method and call that addBalloon (make sure to add it to the interface too):
We’re going to use this method to create a balloon and send it upwards. Don’t forget to also declare this method in the Game.h file.
The first thing we are going to do is add in a balloon image of a random color, and place it at a random location below the screen. Place this code in the addBalloon method we just created.
image.x = (arc4random() % (int)(self.width-image.width));
image.y = self.height;
Notice here that i used imageWithTexture to use the texture object.

I am not sure if anyone knows or has done some benchmarking, but say I want to slide an object from position A to position B - is an animation more efficient, or is a script doing linear interpolation between the two points as efficient? Are there other, more efficient ways todo this?
In any answer, would the same apply for iOS targets?
P.s. If nobody knows I think I'll benchmark for iOS and post my results
I'd say that animation is faster as it is 1 line of code, and not multiple... But then again, you're calling a whole part of a file, so I don't know...
Yeah I would agree with Justin, as animation would just be reading values to set the transform instead of calculating it.
I tried both in my program and the animation looked smoother to me. That said, I may have had a flawed script and would like if you benchmarked it for the iOS and posted the results.
I asked a question like this before, and just got a bunch of annoying responses telling me to perform tests. I suggest you just post your test results and mark this as answered. Any information would be helpful; taking time to test for best practice on everything is not something some of us care to do; I'd rather be told what to do by someone I trust, so I can actually make games, instead. If I ever happened to come across contradictory results, oh well. I'll accept that possibility in exchange for the time I gain by not testing. :-P
Yep, it's a tricky one. It feels like the animation should be faster as it's fired and the native code can handle it - but how heavy weight is the native code? More so than my C# compiled into native code?
Given that lots of things are working, testing this out might need to wait until I do some re-factoring to make some of the code more production grade, but I'll post the results as an answer for iOS, probably be tested on 3G S.
Answer by Bovine
Jul 17, 2012 at 06:22 PM
So, I'm going to answer this in a slightly dubious way...
We have a tile based dungeon crawler (see link in my bio for a video, coroutines used in this vid) and we were using a Coroutine to move the player from tile to tile but I've now changed this to an animation.

(CAAnimation button)
The “CAAnimation” button invokes the method
- (IBAction)doAnimation:(id)sender. It performs a whole sequence of animations. It does this buy creating a CAAnimationGroup, and then creating a sequence of individual CAAnimation objects of different flavors. It sets the beginTime property of each animation so that each animation step in the animation group begins when the next animation finishes.
What you will learn:
This project demonstrates a wide variety of animation techniques
- Using CABasicAnimation to animate a property and move images around on the screen.
- Using different animation timing functions like kCAMediaTimingFunctionLinear, kCAMediaTimingFunctionEaseIn, and kCAMediaTimingFunctionEaseInEaseOut to get different effects
- Using CAKeyframeAnimation and a CGPath to animate a layer along a curved path (a figure 8).
- Creating a custom subclass of UIView that has a CAShapeLayer as it’s backing layer so you can draw shapes in a view “for free.”
- Adding a CGPath to a shape layer to draw shapes on the screen.
- Using CAAnimationGroup to create a linked series of animations that run in sequence
- Creating a very clean “per animation” completion block scheme using the fact that CAAnimation objects support the setValue:forKey: method. I add a code block to an animation object and set up the animation delegate’s animationDidStop:finished method to check for a special key/value pair with the key kAnimationCompletionBlock.
- Using the cumulative property on animations to create a single repeating animation that continuously rotates a layer by any desired amount.
- Using a CATapGestureRecognizer to detect taps on a view.
- Detecting taps on a view while it animates “live” by using the hitTest method of the view’s presentation layer
- Pausing and resuming animation on a layer.

If you tell Spine what folder to browse for, it will import the images you need for your animation. I named these images as well.
Drag the skin (images) from the right panel onto the bones. To make sure the elements are skinned in the right order, you can select one of the elements in the panel and click ‘+’ or ‘-‘ to move it above or below in the order of slots.
Next, connect the bones to the skin by selecting one of the elements of the skin you just imported and clicking ‘set parent’ in the right panel. Once a skin element is given a bone parent, you can arrange a pose by dragging the bone.
Now that the skins are arranged along with the bones, you are ready to animate! As a demo, I have created a ‘lazy bee’ game interface. This is a sample Corona SDK app where the bee rests on a honeycomb. Feed the bee ‘pollen’ by clicking on it and click on the honeycomb for the bee to fly to its new space. If you don’t feed the bee, it remains in ‘rest’ mode on the honeycomb, moving only slightly.
Click the left-hand ‘setup’ text to toggle to the animate screen. Here is where we start experiencing Flash déjà vu, as we will start assigning poses to keyframes. For ‘lazy bee’, I need to create two animations, one a ‘rest’ state with a pulsing wing movement, and a ‘flying’ state with a looping wing flutter and body wiggle effect.
To do this, click on ‘Animations’ in the right hand tree and generate a new animation. Click keyframe 0 and select it as “Loop start” and 15 as “Loop end”. Then click each keyframe successively and move the bones (with the skin attached) very slightly to make the wings and body move. For the ‘fly’ animation, the wings move more dramatically and more quickly, a setting controlled via the ‘playback’ button. For the ‘rest’ animation, the wings move only a little and over only eight keyframes.
For each keyframe, rotate, translate (moved) or scale a particular bone, and then click the ‘key’ button next to the property to save the keyframe. Unchanged keyframe buttons start out as green, edited keyframes orange, and when changed and saved the button turns red.

And in the ScrollView session this morning, Josh and Eliza showed you how to actually build a Messages like effect with that technique.
Or you can create and add new items on the fly.
The key here is to create the animator with your collection layout instance, add behaviors and add collection view layout attributes to these behaviors.
We are then going to change position and rotation on these instances.
We have some predefined, some convenient support for dynamics for collection view in dynamics.
We take care of invalidating the layout if anything changed in the system and we also pause and resume the animator if your layout is no longer the current layout for the collection view because in collection view, you can switch layouts.
We also provide convenience method for implementing your layout so you can ask the animator itself for layout attribute for cell at index path for supplementary views and for decoration view.
So we know that's a layout so we help you in implementing this method in your layout.
You can ask the animator.
We have, for layout updates, the usual collection view methods, so prepareLayout is usually when you can instantiate an animator or create your initial state and prepare for update which is another layout method, you can add new items to your behaviors.
And there is this very important method in collection view which is layoutAttributesInRect which possibly basically defines where the cells are going to be.
And to implement this method, we have itemsInRect in the animator.
So that's really easy.
You can ask the animator, "Give me all the items you're tracking in this rect."
Then you can combine these items with maybe attributes which are not animated.
Again, the way you design your system will have a direct impact on the number of cells you can animate.
I would like to show you an example of collection view using dynamic for a specific effect.
That's actually an example from the collection view sessions last year when I was dragging a cell in a layout.
So we are going to do that the Dynamics way.
So I select a few cells.
So the effect is maybe a little bit too much but you get the idea.
So we have these cells connected to springs and reacting to the gesture.
And when I end my gesture, I just clear the animator.
[ Applause ]
How complex is that?
You just need to decompose this program.
Why do I need to animate that?
The way I did it, perhaps, there are many solutions to this problem.

In the previous post, I wrote about UIKit Dynamics covering the following behaviors:
This time I’m going to talk about the last two ones,
These new behaviors are implemented in the same way we implemented the behaviors in the list above, however they will behave differently as their name implies.
As usual, let’s assume you have xCode 6 Beta (any beta version) installed, with an empty View Controller set up. Then let’s add a
UIDynamicAnimator and a
UICollisionBehavior just in case:
We will start with the push behavior. Note at line 18, for the purposes of this tutorial, we have added a transform to our greenBox to rotate it a little bit (45 degrees). Now let’s declare a push behavior and instantiate it. Then add it to our dynamic animator:
The Push Behavior:
The push behavior is very simple. Basically, the UIView that receives the push, is “pushed” away in a specific direction and speed, based on the push settings. In the real world, an object that is pushed, would stop because of gravity, friction and other physical factors. In the space though, if you push an object, it will travel forever in that trajectory, until it finds some meteor to smash into. But that’s another story.
It’s important to know that this behavior has two modes:
UIPushBehaviorMode.Continuous. The Instantaneous mode makes the UIView receive only one push per time. That means that after some time, the movement of the object slows down until it stops (unless you give a high elasticity to the object for example, at that point it will bounce around forever).
On the other hand, the Continuous mode, will push the object repeatedly, adding to each time more speed to it gradually. This would be ideal for rockets, cars and space ships. If you do game development this could be useful.
In the code above, the push mode is Instantaneous, so the box is pushed upwards, colliding to the edge of the screen and bouncing back. Note that we don’t have any gravity set up in this example. At line 30 we have are adding both an angle of -180 degrees to the push (upward direction) and a magnitude value, which is the “strength” of the push.

You will find a full (seems to be) list of the dictionary and anim names here: http://docs.ragepluginhook.net/html/62951c37-a440-478c-b389-c471230ddfc5.htm
Important: You need to request the animation Dictionary before start using it in your script:
Native.Function.Call(Native.Hash.REQUEST_ANIM_DICT, sDict) sDict – The anim dictionary
To check if the Dictionary was loaded you can use:
Native.Function.Call(Of Boolean)(Native.Hash.HAS_ANIM_DICT_LOADED, sDict) sDict – The anim dictionary
Handling the animations
To handle the anims we have some interesting methods like:
-STOP_ANIM_TASK -IS_ENTITY_PLAYING_ANIM -GET_ENTITY_ANIM_CURRENT_TIME -SET_ENTITY_ANIM_CURRENT_TIME -SET_ENTITY_ANIM_SPEED
Native.Function.Call(Native.Hash.STOP_ANIM_TASK, thePed, – Ped playing the anim sDict, – Anim dictionary sAnim, – Anim name speed) – Stop speed, used for smoothness control
Native.Function.Call(Of Boolean)(Native.Hash.IS_ENTITY_PLAYING_ANIM, theEntity, – Entity/Ped playing the anim sDict, – Anim dictionary sAnim, – Anim name 3) – Unknown
Native.Function.Call(Of Double)(Native.Hash.GET_ENTITY_ANIM_CURRENT_TIME, theEntity, – Entity/Ped playing the anim sDict, – Anim dictionary sAnim) – Anim name
Obs.: The time returned is a number between 0.0 and 1.0 (ex.: 0.35), it represent how much percent of total playback was played, 0.35 for example means 35% 😉
Native.Function.Call(Native.Hash.SET_ENTITY_ANIM_CURRENT_TIME, theEntity, – Entity/Ped playing the anim sDict, – Anim dictionary sAnim – Anim name time) – New time
Obs.: The time param here use same idea as the return of GET_ENTITY_ANIM_CURRENT_TIME method, so, to set anim to half playback time you should use 0.5 for example.

Hacking UIView animation blocks for fun and profit
In this article, I'm going to explore a way that we can create views that implement custom Core Animation property animations in a natural way.
As we know, layers in iOS come in two flavours: Backing layers and hosted layers. The only difference between them is that the view acts as the layer delegate for its backing layer, but not for any hosted sublayers.
In order to implement the
UIView transactional animation blocks,
UIView disables all animations by default and then re-enables them individually as required. It does this using the
UIView doesn't enable animations for every property that
CALayer does by default. A notable example is the
layer.contents property, which is animatable by default for a hosted layer, but cannot be animated using a
UIView animation block.

For example, if you want to make something drag-able on a canvas, you need to deal with at least three events: You need to begin a drag when the mouse is pressed, update when the mouse is moved during a drag, and terminate the drag when the mouse is released. Also, you need to preserve state. And this is exactly what behaviors allow you to do. Behaviors let you encapsulate multiple related or dependent activities plus state in a single reusable unit.
We will explain more details in future posts.
Target & Source
As we talk about Triggers and Actions, there are a couple of other important pieces that play into this. Let’s repeat the sentence from above, slightly modified:
When I press the “open exit door” button, the exit door opens.
This is getting rather colorful. Let’s look at the magenta part of the sentence first. Imagine we have a room with multiple doors that can be opened from a control panel. “The door opens”, as in the original phrase, is not specific enough, we need to know which door the “open” action should be applied to. Many actions therefore have a Target property that points to the element that the action should be applied to.
As you apply Actions by dragging & dropping them on a UI element on the artboard, we make the object you are dropping the Action on the default target for your Action. We also give you a property editor in the property inspector that lets you choose any other object in the scene as your target.
The first part of the original sentence also is not specific enough: “When I press the button” does not really tell me which button. The revised sentence therefore has a clarification, in orange, that clearly states which button we mean. Many Triggers therefore have a Source property that allows you to configure on which UI element your trigger is supposed to listen.
Next in this series, we will discuss an example Action. Stay tuned…

This is a demo project that illustrates various animation techniques
It shows 3 different kinds of animations:
- A simple UIView animation that animates an image in a straight line while increasing the scale of the image and rotating it around it’s axis
- A “clock wipe” animation that gradually reveals an image in a circular arc like a radar display, then hides it again
- A complex sequence of animations that are managed using a CAAnimationGroup.
UIVIew animation (View Animation button)
The UIView animation is performed by the method
-doViewAnimation: (id) sender in viewController.m. It uses the method
animateWithDuration:delay:options:animations:completion: to do it’s job. UIView animations modify animatable properties of one or more views. It is possible to animate mutliple animatable properties of multiple view objects with a single UIView animation call. the doViewAnimation method animates the view’s center, scale, and rotation all at the same time.
Clock Wipe animation (Mask Animation button)
The clock wipe animation is performed in the method
- (IBAction)doMaskAnimation:(id)sender;. It works by creating a shape layer (
CAShapeLayer) and setting it as the mask for an image view’s layer. We set the shape layer to contain a an arc that describes a full circle, where the radius of the arc is 1/2 of the center-to-corner distance of the view. The line width of the arc is set to the arc radius, so the arc actually fills the entire image bounds rectangle.
CAShapeLayers have a properties strokeStart and strokeEnd. Both values range from 0.0 to 1.0. Normally strokeStart = 0 and strokeEnd = 1.0. If you set strokeEnd to a value less than 1, only a portion of the shape layer’s path is drawn.
doMaskAnimation method sets
strokeEnd = 0 to start, which means the path is empty, and the entire image view is hidden (masked.) It then creates a CABasicAnimatimation that animates the strokeEnd property from 0.0 to 1.0. That causes the layer’s path to animate an ever-increasing arc. Since the line thickness for hte shape layer is very thick, the arc fills the entire bounds of the image view, revealing an ever-increasing portion of the image view.
The animation looks like this:
CAAnimationGroup animation.

--include the Spine library local spine = require "spine-corona.spine” include the json file generated by Spine local json = spine.SkeletonJson.new() local skeletonData = json:readSkeletonDataFile("animations/bee.json") --draw the skeleton using the data local skeleton = spine.Skeleton.new(skeletonData) --dress the skeleton with the image files function skeleton:createImage (attachment) return display.newImageRect("animations/images/" .. [attachment.name](http://attachment.name) .. ".png",100,100) end --place the animation on the screen in the right position skeleton.group.x = display.contentWidth/2 skeleton.group.y = display.contentHeight/2 skeleton.flipX = false skeleton.flipY = false --get ready to make it move local stateData = spine.AnimationStateData.new(skeletonData) local state = spine.AnimationState.new(stateData) --set it to its ‘rest’ state state:setAnimationByName(0, "rest", true, 0)
You can see the final product here:
In this tutorial, I’ve outlined the bare minimum you can do with Spine. I highly recommend it for use in your games and mobile apps when you need to liven up your interface with an animation. With this tool, complex animations become manageable for even the smallest Indie development shops.

For instance, if what you're animating is a view of something on the screen, you can define a subview, apply a scale transform or change the size of the subview or something like that.
Again, we need an initial state, we need to correct the initial state, so we need a size and we need reasonable position.
As I said, MAXFLOAT is not a reasonable position.
What can you do with that?
One interesting use case for dynamic items is to sanitize or change the value we sent.
You can use a single dynamic item to actually animate the same way many different things.
You can map position or rotation, which are the only two values we compute to something else, like mapping to scale transform or instead of animating a rotation, animating a 3D effect.
So if you need to animate something which is not a view or a collection view layout attribute, do not define a view hierarchy on the side just to be able to use dynamics.
Use a dynamic item.
So let me introduce a really stupid example of dynamic item which doesn't display anything on screen, well, depends on what you call screen actually.
You could just log what we compute.
You could keep everything in a dictionary.
You can do whatever you want with that.
Let's talk about collection view.
In collection view, you can use Dynamics in three different ways.
You can decide to use Dynamics for very specific animations like when you're selecting a cell and you want a very specific effect for that selection for instance.
In that case, you just need to create a dynamic animator as this animation or interaction and just remove it after that.
The other thing you can do is to animate a subset of a layout like you have a few cells, you want to drag these cells and after that, you're done.
So you can combine animated and non-animated cells.
You can build an entire layout with Dynamics that works for, well, non-huge data source.
Problem is, in dynamics, what is off screen in the system might impact what is on screen.
So even if you just generate cells on screen for what is visible, you might need to simulate the entire system.
[ Pause ]
Again, you need to provide some initial state for your items and you have many ways to do that, you can compute that initial state, create layout attributes for that state, and feed that to dynamics.
You can subclass an existing layout.

I don't want to put you off, but this is by far the longest project in the series. It's not the most complicated, but it's long, coming in just short of 500 lines in total. That said, I hope it'll be worth it, because the end result is great: we're going to make a Fruit Ninja-style game, where slicing penguins is good and slicing bombs is bad. I think I must unconsciously have something against penguins…
Anyway, in this project you're going to meet
AVAudioPlayer, you're going to create
SKAction groups, you're going to create shapes with
UIBezierPath, and more. So, it's the usual recipe: make something cool, and learn at the same time.
This project is hard because you need to write a lot of code before you can start to see results, which I personally find frustrating. I much prefer it when I can write a few lines, see the result, write a few lines more, see the result again, and so on. That isn't possible here, so I suggest you make some coffee before you begin.
Still here? OK!
Create a new SpriteKit project in Xcode, name it Project23, then do the usual cleaning job to create a completely empty SpriteKit project: remove all the code from
touchesBegan(), change the anchor point and size of GameScene.sks, and so on.
You should also download the files for this project from GitHub (https://github.com/twostraws/HackingWithSwift), then copy its Content folder into your Xcode project.
Please force the app to run only on landscape iPads before continuing.
Reminder: Don’t forget to use a real device for this project, or, if you must, the lowest-spec iPad in the simulator.
LEARN SWIFTUI FOR FREE I have a massive, free SwiftUI video collection on YouTube teaching you how to build complete apps with SwiftUI – check it out!

So this doesn't work:
animation.easingCurve = QEasingCurve.OutBounce
but this does:
animation.easingCurve = new QEasingCurve(QEasingCurve.OutBounce)
The Smoke bindings are capable of doing implicit conversions, though, as Richard Dale pointed out in a recent blog post. So there is hope in the long run. :)
Two more pieces of errata:
- The MovementDirection enumeration for Animations was not being created in 4.4.0; this has been fixed and in 4.4.1 and beyond one can indeed write things like "animation.movementDirection = animation.MoveLeft". Until then you need to use the literal values of the enumeration.

I basically just implemented this UIDynamicAnimatorDelegate so we will know when the animator actually stops and starts again.
So I can just drag that view, there is no other behaviors, just collisions.
So let's add gravity.
So now, when I actually move this view, the effect is, of course, completely different.
It's moving a little bit too much, motion sickness is not something that I would like to have in this demo.
So we're going to add a UIDynamicItemBehavior which is a way to set up some low-level properties.
I'm going to set up resistance which a way to apply damping on velocity.
So the feel is completely different.
I could add a force behavior going to the right, an immediate instantaneous impulse behavior and keep my attachment behavior.
So I see that this force on the view that's trying to move it to the right, so let's stop that.
And the other thing is I could also change those that are low-level property on this view like the elasticity which is the restitution on collision.
So we have a view which is obviously really happy [laughter] to be here.
So let's just turn off collisions and that's the end of this demo.
[ Applause ]
And each action was just really add or remove behavior.
So what do that means?
It means that the effect you want is really about building a behavior tree.
And the behavior tree can be using predefined behaviors like a collision behavior.
But maybe your own behavior is like a magnet-like behavior or a drag behavior which are going to be built on top of these predefined behaviors.
And then you need to associate items to these behaviors, and that is something that you can do at your high-level behavior API level.
You could directly add the same items to predefined behaviors or only add just one to something just for a while when I want to drag this item.
How do you build your own behavior?
You just have to subclass UIDynamicBehavior.
And let's say I want to implement, again, this BouncyFallBehavior.
I'm going to define initWithItem initializer.
How do I implement that?
The first thing I need is to actually create the sub-behaviors for my high-level behavior, so I need gravity and collisions here.
If needed, I will configure this collision behavior.
And the last thing is adding these two behaviors I just created as children to myself.
And that's it.

In this tutorial, I’ll show how to create a simple two-part animation: a bee that has two states, fluttering, and pausing.
To begin, you need at least the trial version of Spine. Download it at esotericsoftware.com/spine-download. Note, you won’t be able to export any files to use in your mobile apps until you buy a version of the software, either the Essential version at $60 or the Professional at $249. Most of the functionality an Indie developer needs is included in Essential, so I recommend buying it if, after the trial version shows you Spine’s capabilities, you think you could use it in your projects.
You will need some art to begin your animation. If you create your own, make sure to draw each animatable element on its own layer in Pixelmator, Fireworks, or Photoshop. Heads, necks, arms, torso, and legs all need to be on their own individual layer. I visited VectorStock.com and bought an image of a bee. The download includes an Illustrator file that allows you to isolate the four elements of the bee I want to animate: head, torso, and two wings. I saved those elements as four separate .png files. It’s a good idea to place the elements of your animation into the folder that will be its final home in your app so that you don’t have to change paths to images later on.
Before you start, consider adding a placeholder of the basic image to Spine so that you get your bone placement right. You can import it with the image fragments and delete it at the end of the animation process. You might prefer to set its opacity low or colorize it to remind yourself to delete it later.
I started by creating a new ‘skeleton’ (Cmd+n / Ctrl+n) in Spine and drawing the four elements of the animation – head, body, and two wings. I named each ‘bone’ of the skeleton appropriately. To do this, make sure you are in the ‘Setup’ area of Spine (the ‘Setup’ text toggles if you click it, between the Setup and Animate states). Click ‘create’ in the toolbox and draw the bones onto the grid. If you get stuck, make sure your screen looks like the one below.
Once you’re satisfied with the way the bones look, you need to import the images that will ’skin’ the bones.

Note that these files are not compiled by Xcode; they are packed into the application’s bundle, then extracted and compiled at run time by the view controller’s
The template’s animation is driven by a
CADisplayLink instances automagically fire a target/action when the device needs a new frame to display. They’re a little opaque, but seem to represent the iOS version of vsync. The view controller sets up and tears down
Note that the view controller creates the
CADisplayLink with the
displayLinkWithTarget:selector: method, which retains the target. To avoid a retain cycle, the view controller itself maintains only a weak reference to the
It’s a small point, but if you look at the view controller’s
drawFrame method, you’ll note that the “square’s” vertices are actually rectangular; they describe a rectangle 1 unit wide by 0.66 units high. Nevertheless, the object appears square when displayed. Why is this?
The answer lies in the physical properties of the display; iPhone screens have a 2:3 width:height ratio (e.g., 320 x 480 square pixels). Absent other transformations, the point
(-1, -1) will be mapped to the lower-left corner of the display, and the point
(1, 1) to the upper right. Since the physical display is rectangular, this will “squeeze” the image horizontally, transforming the given points into a square.
Naturally, this issue is handled more rigorously in production code.
OpenGL ES (especially 2.0) can be a big pile of strange the first time you look at it, so it was nice of AAPL to provide a template that not only takes care of all the mechanics needed to get something on the screen, but that also effectively illustrates some of the surprising things in the API. Xcode’s “OpenGL ES Application” template is really a nice little tutorial, and will reward your study.

Get all QuartzCode project examples in one link. Just open and play using QuartzCode.
Basic Usage Tutorial
Shows basic on how to use QuartzCode including adding timeline, multiple animations, and shared color.
Tips using Timeline Panel
Show tips and tricks when using Timeline Panel.
Spinning Indicator using Replicator
Shows you how to create a basic replicator layer by creating a spinning indicator.
Car Animation with Smoke Emitter
Shows you how to use multiple emitter cells applied to a car moving on a path.
Reload Animation with Nested Groups
Shows you how to create reload animation with nested groups
Shows you how to use shapes to create hamburger animation.
Text Animation using Effect Layer
Shows you how to animate text glyphs by using Effect Layer
How to Use Generated Code in Xcode
Shows you how to use generated code in most basic way.
Explain how to combine layer types and multiple animations to produce a complex animation.
Water Fill Animation
Combination of path, transform and position animations with parent/child layer to create water fill animation
Percentage Vote Animation
This tutorial includes on how to use mask and edit generated code in Xcode to control the vote percentage.
Creating load, complete and fail animations
Shows how to use multiple animations in QuartzCode with Xcode use case project.
Round Progress Animation
Example on how to create rounded progress animation.
Xcode Example Project
Xcode project with example with relative frame, reverse animation, total duration and end time options. Contains both Objective-C and Swift project.
Multiple Text Animations
Various examples for simple text animations
Rebus Zone Examples
QuartzCode projects with animations from Rebus Zone app. Thanks to Alexander Burtnik for providing such a good samples!

And lastly the last parameter is if you want to use seconds or frames. I’ve always left that to true meaning use seconds, that way if you change the framerate of your movie, it doesn’t change the timing of your animation.
So if you test your movie, your rectangle will go from left to right in three seconds. Pretty boring, but it’s your first animation. What we can do next is affect more than one property at the time. But for that, we have to create a new tween for each property we want to affect.
var myTweenX:Tween = new Tween(rectangle, "x", Strong.easeOut, 0, 300, 3, true); var myTweenAlpha:Tween = new Tween(rectangle, "alpha", Strong.easeOut, 0, 1, 3, true); var myTweenWidth:Tween = new Tween(rectangle, "width", Strong.easeOut, rectangle.width, rectangle.width + 300, 3, true); var myTweenRotation:Tween = new Tween(rectangle, "rotation", Strong.easeOut, 0, 90, 3, true);
So here our rectangle fades in, moves to the left, becomes wider and turns right. Two things to see here. First the alpha property doesn’t work like in actionScript 2. Before, it ranged from 0 to 100; in ActionScript 3, it ranges from 0 to 1. It’s a minor difference, but you have to know it. Also as you can see with the width tween, you can put variables in the fourth and fifth parameters so that you don’t really know the beginning and ending values.
That is it for now, I’m going to bed, but later on I’ll add stuff about easing and how to time animations.

We're going to determine whether or not it was canceled or not, in which case we're either going to call CancelInteractiveTransition or FinishInteractiveTransition depending on the direction.
In this case, it's finish.
And then, again, we're going to call the completeTransition block on our method, on the transition context.
So what did we learn here?
First of all, Dynamics and custom transitions are compatible with each other.
They can be used.
In fact, we spend a lot of times trying to make sure that our APIs compose well together.
As a rule of thumb, it really pays off to create composite behaviors that get the function that you're interested in.
We showed how you can create complex dynamic transitions using the dynamic animator delegate, the collision behavior delegate, and actions on dynamic behaviors.
A dynamic behavior subclass can easily conform to one or even both of the transitioning protocols.
It makes a lot of sense to do so because you can put all of the logic in one place.
Duration is something that needs to be thought about when you're doing transitions.
Again, a dynamic system doesn't necessarily converge ever.
So you want to put checks in place based on your application logic to ensure that it finishes.
And then, what's interesting is that dynamic behavior actions can actually be used to drive the interactive portion of a transition.
And that might not be entirely obvious.
I'd like to make one other point and that is, is that if you're using Dynamics and you add behavior to the dynamic animator and nothing happens which has happened to me a few times, it's probably because you didn't retain your dynamic animator.
Don't let that happen to you.
So quick wrap up.
When you're using dynamics, focus on what it is precisely that you're really trying to do in small pieces.
It really helps to build complex dynamic interactions and animations piece by piece.
In fact, we are iterating all the time when we create this.
You're going to have different constraints that you want to take into account, duration, interactivity, et cetera.
There's all there's a whole other bunch of new animation APIs that we added in iOS 7.
Those might be more suitable in many cases.
For example, there's an animate with duration API that allows you to implement kind of a simple spring animation as well.
So look at those two.
And then just go to town, create awesome stuff.
All these sessions, I believe have already happened but you can look at them on the videos.

A video that demonstrates the use of Adobe Flash for creating sprites for use in animation in games. In this video, a game character is shown doing various actions which range from simple stance's to complex combo's The video explains the use of sprites and keyframes to be used in various actions. It also explains the use of pauses while executing the sprites so as to add fluidity to the action performed. This also reduces the number of frames required to perform an animation. Lastly, the narrator demonstrates how to draw the next keyframe in a sequence using an earlier keyframe as a reference.

And at the appropriate time when you are either pushing or popping or presenting or dismissing, we're going to ask that delegate to vend an animation controller or an interaction controller.
So the methods that those objects that your delegate vends need to implement are various few.
The main one for the animation controller is funny enough, animateTransition.
And for interactive transition, it's startInteractiveTransition, kind of pretty simple.
These two methods are passed in a special object called the ContextTransitioning object which defines the characteristics of the transition.
It defines where views start, where they end.
It also is a little bit active and that we define some methods that need to be called at certain points in time.
So basically, the declaration of the protocol looks something like this.
There is a container view.
That's the view in which the tran the animation takes place for the transition.
There are some methods to query to find out where I'm supposed to end up.
And then, there are those action methods that are on the context.
And for interactive transitions, there is a few of them.
There is updateInteractiveTransition with a present, and then there's either Finish or Cancel.
And finally, when the transition is all over, and this is true for both interactive transitions as well as just regular, straight up animated transitions, you must call a special method called completeTransition indicating whether canceled or not.
And this basically patches up any data structures and puts things into a consistent state so your application can move forward.
It moves as a little bit to talk about the different states involved in an interactive transition.
I've kind of broken it into a few sections.
The first four kind of where you go from nothing, you're in no particular transition mode to the interactive mode.
And you might consider this, if you're doing a pop gesture, it's as your finger is down and you're dragging across the screen.
When you release that, your finger, the transition isn't over yet.
It still needs to do something.
It's either going to animate off or animate back to where you started.
And the decision of which direction you're going in is really up to you in your code.
And so you can either cancel the transition or continue it.
And once you do, you then animate it to completion and call the completeTransition method.
So it's really kind of that simple and if you are interested in more details, you can look at the video of this morning's talk and there are also some docs available for that.

So for complex sequences they’d simply just be queued up series of fundamental animations in cards, and then I can easily just interlace calls to PlayAnimation() and SubmitActions() and treat them almost identically in code as opposed to the one-off hacks for each ability that currently exists. But even that process is rife with a lot of edge cases due to the dynamic nature of how players interact with cards, and ultimately would still require some programmer help to get things looking right.
For the moment, card animations in SFT are created by:
- The artist creates a fully animated mock up in Unity using the tools they know. Artist now exits stage right.
- I then painstakingly try to mimic that entire flow (and very often other user flows not captured in the 1 one-off mock up) using a combination of animation clips, splines, FSMs, and procedural animation via code.
- Give up trying to replicate the mock up when enough time has gone by and I realize I have to move on.
I’m able to capture the majority of the mock up’s “essence”, but a lot of the subtleties of the animation that artists are actually good at creating are lost due to lack of time and lack of flexibility. Maybe next go around if we’re doing another card based project I’ll be able to have another go at this.

ActionScript 3 Tweens Tutorial
Since I think it’s something people want, I am going to do a tutorial about using ActionScript 3 to do animations. I recently made a new tutorial about using Tweener instead of the Tween classes, or even better, how to use TweenLite (TweenLite is smaller and faster than Tweener). I think it is better to use Tweener or TweenLite because it is easier to understand and it takes way less lines of code.
In this tutorial I’ll be using the Tween Classes already bundled in Flash Cs3. There are other ways to do this but I find it’s the easiest. You could do the same using onEnterFrames or Timers or the Zigo Engine (but it’s not yet AS3).
Ok first thing you will need to do is to draw a rectangle on the stage and then convert that shape to a movie clip. After that, give it an identifier name in the property inspector. Let’s name it “rectangle”. Now open the actionScript Window by pressing F9. Create a new layer on the timeline, name it actions, and start writing your actionscript there. The first thing we will need is to import the actual classes for tweening. Add these to line of code at the start.
import fl.transitions.Tween; import fl.transitions.easing.*;
The first line is to import the Tween, the second one is to import the Easing classes. I’ll explain what easing is later on.
Now all we need to do is add one line of code to make the rectangle move.
var myTween:Tween = new Tween(rectangle, "x", Strong.easeOut, 0, 300, 3, true);
This create a new tween object with its properties in the parenthesis. The first parameter is the object you want to animate. The second parameter is the property of that object that you want to animate. You can animate a lot of properties for a display object example: x, y, alpha, width, height, xscale, yscale, rotation etc. I’ll give some example later. The third parameter is easing. Fourth and fifth parameters are the starting and ending position of the property you are animating in this case, the rectangle will go from the x position 0 to the x position 300. The sixth parameter is the duration of the tween, in this case 3 seconds.

And then, we're going to set up the action block again.
And this time, it's a little interesting.
First of all, there's a bug in that line where I'm setting the finish time.
It really should be two-thirds of the duration not two-thirds of the elapsed time, but you get the drift.
And that's because it's two stages.
I'm going to spend two-thirds of my duration doing the first half of my or first two-thirds of my transition.
And then, I'm going to move over to the next bit.
And the way again I'm going to trigger that, is I'm going to remove the behaviors which is then going to cause me to go into the DidPause animator's delegate method.
I do the regular dance of adding the children behaviors.
I do something different based on whether or not I'm a whether or not I'm presenting or dismissing, that's why there's an IF clause for the attach behavior and then we're going to run.
[ Pause ]
So now, we've come to rest.
DidPause gets called.
Now, it either got called because the system came to a rest or because we actually hit our elapsed time.
And we're going to do the same thing.
Now we're using the attach behavior a little bit as a semaphore here because the dynamic animator DidPause is saying, "Hey, do I have an attach behavior?
If I do, then I need to go into the second step of my simulation."
So I'm going or remove the attach behavior, clear out that reference to it.
I'm going to add myself back to the dynamic animator and I'm going to change my finish time.
Now time has elapsed, so animator elapse time is actually not going to be 0 at this point.
And now, I only want it to run the remaining one third of the specified duration of the transition.
At this point, since the attachments disappear I should have pressed that button before.
Since the attachments disappear, when I run it, I'm going to hit this point.
And now the collision delegate is going to kick in because now, I want to do something after that first bounce.
I basically want to remove the collision behavior so that on the next drop, it's going to drop all the way off the screen.
And I want to check that I actually bounce off the edge I care about.
So it's possible that I might have hit the right edge and I really want to just trigger this code if I hit the bottom.

Feel free to add the other animations yourself. For example, the “jump” animation is on frames

So this is kind of a demo that shows all kinds of transitions, but I'm going to show you the drop dialog.
Now, this thing comes in as little dialog.
What's interesting about this is, first of all, this is on a phone and we're doing a present view controller and guess what, I can see the presenting view controller.
You couldn't do this really on the phone before.
So now, you can implement your kind of faux form sheets or foe popovers right on a phone.
But you'll notice that bounce that came in.
So it comes in with a bounce and I'd also like to show that when we created that dialog view, before it animated in, we did something that I'm not sure if we can see it.
Well, what is supposed to be shown here is some of that parallax where we layer these dialog views.
And there's new API which is available, I believed, in the seed that we delivered called UIMotionEffect.
And you can put a UIMotionEffect on to a view and then animate it directly.
And if it was working, I would show it to you, but it isn't so you'll have to take my word for.
Now that was a present.
Let's see what happens when I dismiss.
Now the first thing that happens is we slide off to the side and then we bounce off and go away.
That's kind of a two step simulation.
So how did we do this?
Let's talk about that.
So I'm going to show quickly some of the steps and there's going to be a lot of code up here, so bear with me.
The YYDropOutAnimator is the animator object which is a subclass of dynamic behavior that I used to create this effect.
And everything here is just a consequence of this specific implementation and it's broken up into a few things.
First of all, you'll notice that it conforms to a bunch of different protocols.
It conforms to the animated transitioning.
It conforms to the animator delegate and conforms to the collision behavior delegate.
This is some of the power of using protocols, first of all, that you're not bound to a specific instance and you can kind of mold the objects of your choice for implementing certain behaviors in the system.

Hope this One is Easy
Animating 2D sprite upon movement script help.
On collide animate
2D Sidescroller: Change camera position?
GetComponent on iOS?

I’ve created an animation using a few different methods that runs in a browser and is responsive (works on both mobiles, tablets and desktop). You can see it here:
I’ve used a CSS keyframe animation for the clouds, and moving the scenery. Very basically, this moves the clouds from the very right to the very left. This animation is declared once as a mixin (using SCSS), and is added to each cloud individually, so the appropriate speed can be set. To make sure the starting value looks a bit random and the clouds are evenly distributed, I’ve given each cloud a different animation-delay time of a random number, making it look like the animation’s already started when the page loads.
GSAP timeline animation
I’ve been using GSAP (Greensock) recently and it’s so useful. I used TimelineMAX, which allows you to make a timeline of tweens, and adjust the timings without having to mess about adjusting percentages like you’d have to with a CSS animation. The GSAP timeline makes the bomb fall to the floor by adjusting a transform position and rotation, and then trigger the explosions to show by changing them from display: none, to display: block. Then moving them left to make it look like we’re leaving them behind.
Spritesheet animation using CSS keyframes
The explosion contains 7 frames on one image, and uses a CSS keyframe animation to move it horizontally between the frames. You can use the steps() property of the animation so jumps to each frame instead of animating across. I also used animation-fill-mode: forwards to always stay on the last frame so that it doesn’t loop. These animations will play once when first shown. Nice and easy.
Spritesheet animation using GSAP
Just because I like the experiment with different methods, I animated the pilot’s scarf using GSAP. It’s the same method as the explosions, but using a separate GSAP timeline which uses transform: translate to move through the frames and repeats infinitely.
I can’t actually think of many advantages of using GSAP for this, except if you wanted control over pausing it or changing the speed dynamically.
Here’s a video of the animation:
If you’re wondering where the graphics came from, I’d already created them as vector files for my Chicken Fokkers Android game which you can get here, and I’ve written about progress here.

When you create this thing, you're usually create the delegate is usually creating it and when the delegate is asked, it's actually passed in a transition context and we scroll that away in the animator because we want to be able to use it in the dynamic behavior callbacks.
We know whether or not the dialog is being presented or dismissed.
And, again, the delegate, when it's called, has that information.
We set the finish time.
The finish time is, I think, I was alluding to before which is I don't want this transition to take too long.
So I want to say, "I want it to be done no later than this point in time," and we're going to check that value in the animator's callbacks and the dynamic behavior's action method.
And finally, we're going to this is a composite behavior and we are going to scroll away various primitive behaviors that are actually going to be added and removed, these children behaviors as Olivier demonstrated a little bit earlier.
So, amazingly enough, I scrolled away in the corner of my office with some green felt that wasn't being used, and I used it to create kind of a visual image of what a view controller screen might look like.
And basically, we're getting called with animateTransition.
This is an interactive transition.
It's a straight up animation and the question is, now, how do we hook up the Dynamics to the system?
Well, the first thing that we have to do is we have to figure out what's moving and what we actually want to apply forces and the like to.
And a lot of this code is alighted, so I apologize for that.
But there's this thing called the dynamic view.
The dynamic view is the view that's moving.
It's just a name.
When it's called, the first thing that we do is we add that dynamic view into the view hierarchy.
It so happens that it's above the screen because it's going to drop in.
And then, we start creating some of our primitive behaviors like the dynamic item behavior where we set up an elasticity, we have the dynamic view to that primitive behavior.
And for the first segment of this transition, we don't want to allow any rotation.
Then we add some gravity.
Gravity is a pretty simple primitive behavior.
It's going to be three times normal gravity.

We add a collision behavior and you'll notice that the way that I set the bounce on the collision behavior is using a slightly different method on the collision behavior, set translate reference bounds into boundaries with insets.
That's actually a very useful method because you can kind of take the reference coordinate system and move it in different directions based on simple UIEdgeInsets.
So now let's talk a little bit about the finish time.
Basically, we query the dynamic animator for how much time has elapsed.
It so happens in this case, it's going to be 0 but, you know, for sake of being true, we ask the elapsed time then we add the duration that was scrolled away when we created the behavior object.
And we create an action block and that action block is going to check whether or not the time has passed that we want to dedicate towards this transition.
And if it has, there is a very simple way to finish.
We basically remove ourselves from the dynamic animator.
Now, to get things going, we have to add the children behavior to ourselves, remember, we are a compound behavior.
And then, we have to add ourselves and there's only one behavior now that's being added to the animator and that is us.
And at this point, the physics engine is going to start and we're going to start simulating our transition.
And there you have it.
So we've transitioned.
We're done, it's up on the screen and now, we're going to hit the good to know button.
And we're going to do the dismiss, and the dismiss is a two-stage thing.
Again, we call animateTransition.
We don't have to add a view into the view hierarchy.
This is a dismiss, it's already there.
We're going to set our dynamic item behaviors up a little bit differently.
We're going to allow rotation this time.
Gravity is set up exactly the same as it was before.
Our collision boundaries are a little bit different and that's because the type of animation that we're trying to achieve is a little bit different.
We're going to add an attachment behavior where we're going to kind of try to anchor we're going to specify a different position in the default.
The default is usually the center of the item.
We're going to kind of put it up to the top and we're going to put the anchor a little bit off to the side.
We're going to give it a little bit of kind of bounciness.

Build and see:
If you change the push mode to
UIPushBehaviorMode.Continuous, the box will hit the edge of the screen bounce a little and still move upwards, sticking to the boundary trying to get through it, of course, the poor little green guy, will never get out of there:
Let’s make it a bit more interesting, by pushing the green box only when tapping on it. For that we will need to add a simple
UITapGestureRecognizer and handle it. Follow along:
We are handling the tap gesture into the
onTap() function and, at line 44, we are adding a new direction and magnitude force to the push behavior (which is already attached to the green box instance). This time, instead of removing and re-adding the behaviors to the animator, we just deactivate and activate back the push behavior to renew it and thus make it work every time the green box is tapped:
As you see in the image above, we are literally dribbling the box making it bounce on the ceiling of our screen waiting for it to come down to re-push it back. Pretty neat he? You can even call
setTargetOffsetFromCenter which takes the an offset value which is the location of the push. If you push the object from a corner, the object will literally rotate from there accordingly. See the relating Apple documentation for more info.
The Snap Behavior:
The Snap behavior, or
UISnapBehavior is very straightforward. All it does is telling the object to snap back to some position, usually an original position. Let’s set up some code for this example. We will declare the snap behavior, instantiate it giving it the location to snap to (in this case the center of the screen), and we will add a
UIPanGestureRecognizer. If you are not familiar with pan gestures, please I recommend reading my previous post which covers it in details. From there will add the snap behavior to the animator whenever the pan is ended or on
UIGestureRecognizerState.Ended. This way when the green box is released, it will snap back to its original location with a cool, elastic transition. Check out the complete code code:
At line 58 we are adding the snap behavior to the animator. We also have to remove it every time we try to drag or push (by tapping) the green box, thus we did at line 46 and 65.

To define interaction in your app, you make your view controller files communicate with the views in your storyboard. You do this by defining connections between the storyboard and source code files through actions and outlets.
An action is a piece of code that’s linked to an event that can occur in your app. When that event takes place, the code gets executed. You can define an action to accomplish anything from manipulating a piece of data to updating the user interface. You use actions to drive the flow of your app in response to user or system events.
You define an action by creating and implementing a method with an
IBAction return type and a
sender parameter points to the object that was responsible for triggering the action. The
IBAction return type is a special keyword; it’s like the
void keyword, but it indicates that the method is an action that you can connect to from your storyboard in Interface Builder (which is why the keyword has the
IB prefix). You’ll learn more about how to link an
IBAction action to an element in your storyboard in Tutorial: Storyboards.
Outlets provide a way to reference interface objects—the objects you added to your storyboard—from source code files. To create an outlet, Control-drag from a particular object in your storyboard to a view controller file. This operation creates a property for the object in your view controller file, which lets you access and manipulate that object from code at runtime. For example, in the second tutorial, you’ll create an outlet for the text field in your ToDoList app to be able to access the text field’s contents in code.
Outlets are defined as
@property (weak, nonatomic) IBOutlet UITextField *textField;
IBOutlet keyword tells Xcode that you can connect to this property from Interface Builder. You’ll learn more about how to connect an outlet from a storyboard to source code in Tutorial: Storyboards.
A control is a user interface object such as a button, slider, or switch that users manipulate to interact with content, provide input, navigate within an app, and perform other actions that you define. Controls enable your code to receive messages from the user interface.
When a user interacts with a control, a control event is created. A control event represents various physical gestures that users can make on controls, such as lifting a finger from a control, dragging a finger onto a control, and touching down within a text field.

Please check this app:
Screenshot from that app is shown below:
Can you please let me know how to add an image on touch and have each image animated?
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.
In iOS 5, you can use a sequence of images. First you will need to add a new category method:

So, two examples that we're going to go through.
One is a for lack of a better word, a drop in and out dialog.
It's kind of a dialog which will you will present.
It will be a custom view controller presentation.
It will drop on screen.
It's not going to be interactive.
But what is it going to demonstrate?
It's going to demonstrate using kind of a two-stage dynamic simulation where we're going to use the action methods and the DidPause methods and so forth to change the Dynamics of the system as the transition evolves.
The second demo that I'd like to deconstruct is kind of just a simple drop shade transition where I'm going to pull down from the top of the screen and I'm going to release it and either it's going to bounce up to the top or bounce down to the bottom.
And the Dynamics there is fairly straightforward, but it's interesting to see how the interaction mode of the transition leverages the dynamic system and vice versa.
So let's talk about the drop in and drop out dialog a bit.
So, it's a dynamic behavior that conforms to the animated transitioning protocol and it demonstrates a couple of interesting things.
It demonstrates the action block which Olivier referred to.
This is called on every step of the simulation, of the physics simulation.
We're going to implement a collision behavior, but we're also going to specify the collision delegate because we want to know when we've hit a certain boundary.
And finally, and this is kind of interesting, we're going to implement the dynamic animator delegate.
And in particular, we're interested in DidPause callback.
And we're also interested in the dynamic animator's elapsed time.
Now, the reason for this is that when you're doing a transition, typically, transitions take a finite amount of time.
You don't want them to take, you know, I don't know, 30 seconds to converge and go.
So you might want to put a bound on it and make sure you're done in two seconds or one and a half seconds or whatever.
And so typically, when you build these systems, you're kind of iteratively trying to figure out how does it look, right?
But you want to actually ensure that the transition takes a certain amount of time.
And you can do that by looking at the elapsed time of the dynamic animator and checking in the DidPause and the action methods.
And we're going to demonstrate that.
So I'm going to show a quick demo of the drop in and out dialog.

And one of few things we have in this class is the ability to add child behaviors, which means that you can use this class to construct your own high-level behaviors.
What's interesting here, if you attach behavior directly to the animator, or if you add a child behavior to a behavior and add this behavior to the animator, there is no difference.
There is no CPU cost or any runtime difference between these two approaches.
So there is no cost for building your abstractions.
[ Pause ]
You can compose your behaviors statically like by defining your own class, adding child behaviors and then never changing these behaviors again or dynamically by adding and removing children for a behavior or from the animator.
So let's see a quick example of that.
Let's say that I want to drag with this real-world effect a view and when my gesture ends, I want to apply gravity to get this bouncy effect I love so much.
The initial setup was just with a collision behavior and that view added to this behavior.
But when my gesture actually begins, what I want to do is to create a new behavior, an attachment behavior, add that to the animator.
And when I update when my gesture is updated, I just need to change that attachment point in my UIAttachmentBehavior and it's going to drag the view as I would expect.
When I end this gesture, what I just need to do is to remove the attachment behavior and at the same time add the same view to a gravity behavior.
A collision behavior is still here, so we are going to add this fall and bounce effect.
That's a really interesting concept and you can build a lot of completely different effects by combining behaviors.
For instance, that example I was using in the first session, a bounce effect is just gravity and collision at the same time.
If I want to drag a view and then at the end of the gesture snap it somewhere else in the screen, I can use an attachment behavior first and then a snap behavior.
Something like the Lock Screen in iOS 7 can be built as a combination of collision, gravity, attachment, and push behavior.
But you can imagine many other things like a magnet-like behavior that you could build from multiple UIPushBehaviors.
So I'd like to show you a very quick demo of the different feel you can get by changing, removing, and adding behaviors.
So a very interesting thing here is the top right animator label is turning green when the animator is active.

Think of the pivot points of the members as the joints of a doll. In order for the doll to move, the joints must be correctly placed, right? The same rules apply for the pivot points.
To move the pivot point, drag the blue circle at the center of each sprite to the correct place (which is the point where it should connect to the parent body part). In the following image you can see the head pivot in its correct place:
The tail part should look like this:
Did you get the idea? Great! Repeat the process for the remaining parts. (You can leave the pivot for the black spot in its center; we'll explain more about this in the next section.) Remember, you want a dragon animation, not a Frankenstein animation.
Once you're finished, click Apply:
If you take a quick look at the folder where you have the sprites, you will be able to see that the dragon sprite now has an arrow next to it:
Press the arrow and you will be able to see all the parts that comprise our dragon character separately:
Assembling the Character
Now that you have your character sliced into different sprites, you can start placing the sprites into the scene. Since the dragon is composed of several body parts, you need to build the character.
The first thing to do is drag the black dot of the dragon sprite to the scene. This object will work as a center of mass for your character. Later on, you will focus your attention there; however, for now, just know that this is the base for your character.
Now, take the body of the dragon and place it over the black dot, like so:
Repeat this process until you have assembled your dragon. By the end it should look something like this:
You finally have your dragon ready—however, as you may notice, it looks weird. Some parts that should be under the body are over it, or vice-versa. That happens because we added the dragon parts without any specific order.
Before we solve that issue, let's turn the dragon sprite into a single game object. As you may have noticed, right now the several parts of the dragon work as individual game objects—you need to group them into a single game object before you can start to animate them.
In order to correctly group all the sprites, use the sprite with the black dot as the main game object; all the other body parts should be grouped under the sprite mass.

I want to create an animator.
Then for each of these attributes, I'm going to need that initial state.
So I'm going to ask flow layout which is the super class.
I changed zIndex because I'm dragging this.
I want this cell on top and I create my high-level drag behavior.
I add this behavior to the animator.
Updating the location and removing everything is extremely simple.
We just update the point or clear the animator.
The layout implementation itself, "Why do I need to define which cells are in this layout for a given rect?"
Some cells might not be animated.
So I start by asking the super class, "Give me all the cells."
Next, I want to remove the cells I'm actually animating.
And then, I need to add the cells I'm actually tracking, the layout attributes I'm actually tracking, from the animator.
So I use this animator itemsInRect method, and I just have to return all these attributes.
And that's it, that's the entire code for this small example.
Now, for some more exciting stuff, UIKit Dynamics and UIViewController Transition, I'd like to ask Bruce Nilo to show you that.
[ Applause ]
Thank you all.
Thank you, Olivier.
My name is Bruce Nilo, and this stage is huge, I've never been on it before.
So I don't know how many of you have been at this morning's talk.
I'd like to get a good sense about custom view controller transitions.
Oh, a lot of you, OK.
So I'm going to kind of breeze through a quick review of what custom view controller transitions are all about.
And then, what we're going to talk about is we're going to kind of build a little bit on what always discussing about how to create kind of compound behaviors.
But these compound behaviors that we're going to create are going to conform to some of these new transitioning protocols that we've defined, and are going to be used to actually implement some custom view controller transitions.
And we're going to walk through a couple of examples showing two different types, and you'll get a sense of how these different things compose with one another.
So let's do the quick review.
First of all, the basic idea is that there's a few delegates that you create and set on your view controller directly if you're doing a present or a dismiss view controller call, or you can implement some new methods on Navigation Controller Delegate or Tab Bar Controller Delegate.

Notice that the Ground element has been expanded to reveal its parameters in Figure 2.
Along the bottom of the grid cells is a green line that indicates the Play Range. By dragging the icon on either end of this green line, you can limit which portions of the animation are played in the Document Window when the Play button is clicked.
Viewing and Selecting Keys
The Animation Palette includes a list of all scene objects to the left and a table of key cells to the right. All keys created with the Animation Controls are displayed when the Animation Palette is opened. Each key is marked in a color that corresponds to its interpolation type, with green for spline-based interpolation, orange for linear interpolation, gray for constant interpolation, and a diagonal line for spline breaks. The actual keys appear brighter and the interpolated frames are the same color only darker.
The table within the Animation Palette grid provides at a glance the available keys and lets you edit the keys by dragging them left or right. At the top of the Animation Palette are the same controls for moving between frames and keys as found in the Animation Controls bar.
You can select a single key simply by clicking it. This will highlight the entire row (representing the element or parameter) and column (representing the frame or time) that the key belongs to. You can select multiple consecutive keys at once by holding down the Shift key while clicking each grid cell. A white box surrounds all keys in the current selection. Figure 3 shows multiple keys selected at once.
Creating and Deleting Keys If you click a grid cell that isn't a key, you can set a key by clicking the Add Key Frames button at the top of the Animation Palette. If the This Element option is selected, a single key is created, but if the All Elements option is selected, keys are set for the entire column. To delete a selected key, click the Delete Key Frames button. Figure 4 shows a column of keys created with the All Elements option.
Sliding and Copying Keys
If you click and drag on the selected key or keys, you can slide the keys to the left or to the right. This is useful when you want to synch two keys to start together. You can copy selected keyframes with the Edit, Copy menu command or by pressing Ctrl/Command+C. Similarly, you can paste keyframes to a different location with the Edit, Paste menu command or by pressing Ctrl/Command+V.

This allows you to specify which animations start together or one after the other and how much time should be left between the animations.
But above all, an animation can pause until the user initiates the process by clicking on it. This allows the animation to be controlled during playback, albeit very limited.
A slightly more sophisticated variant are animation lists that start with defined user input, for example when clicking on a graphic or when dragging objects to other screen areas (drag & drop).
Animation with scripting languages
Also on the change of an existing scene, the animation is based on scripts. A script is a relatively simple and manageable computer program that has been formulated in a scripting language.
With special commands, the graphic objects in a scene can be changed and animated. The graphical objects can themselves be animated pictures (“sprites”).
Many animation packages have their own scripting language (for example, Lingo in Director or ActionScript in Flash). Typical commands are changing the current position on the screen, resizing, or fading in a graphic object.
The advantage of a programmed movement is that you can respond to user input and the current environment of objects. Using simple if-then control structures, it is possible to decide how the animation will continue, for example: B.
- If the object hits a wall, then change the direction!
- If an object collides with another object, then start an animated explosion!
- If you press object A, start the movement for object B!
- If the mouse is over an object, then slow down the movement of the object!
With scripting languages complex movement sequences can be defined and calculated. If motion sequences are to follow physical laws, then the mathematical formulas for position calculation can be implemented in the scripting language.
As a programmer you do not have to worry about the representation of the graphic objects, you only change the properties, for example position, size, color or transparency.
Frequently, the programmed animation steps are started when certain user inputs (mouse clicks, mouse movements, input keys, drag & drop ) have taken place.
Again, the programmer does not have to worry about recognizing these inputs. He only defines the reaction. Scripting languages are therefore a good and – relatively – easy way to design interactive animations.
Animation with calculated frames
Sometimes it is not enough to simply rearrange graphic objects. If complex changes are shown, then the images must be created individually – similar to the single-frame animation.

That one, we don't care.
That one is interesting, that's the first UIDynamicItemBehavior we have in this tree walk.
Elasticity is 0.5.
That is new the new elasticity value for that dynamic item.
Next behavior, we continue.
That's another dynamic item behavior, defining friction, so that's not the same property so that's OK.
We just set the friction to be 0.2.
And then, the last dynamic item behavior we have is setting elasticity to 0.3.
That is the end value.
Then now, let's actually remove this one.
In this case, we are basically going to reevaluate the behavior tree and friction is back to default.
Let's add at the exact same place a UIDynamicItemBehavior changing again the same property.
The new value is actually still 0.3.
So that's the last, it's the most recent behavior I added, but that's not the last in this behavior tree with my definition.
So that is how you can combine behaviors in a very define way.
Dynamic Items, so that's a protocol and that's a way to integrate in Dynamics things that are not necessary views or collection view layout attributes.
It basically defines what we need in UIKit to animate something, so that's a position, a size, and a rotation, knowing that UIView on UICollectionView obviously implement already something like that.
And we only care about 2D rotation.
The engine we run is a 2D engine.
So when you are defining your own UIDynamicItem, the first time this item is added to a behavior, and that behavior is added to the animator, we would get these values, because we need to inject an initial state in the engine.
Then we're going to run the simulation and each simulation tick, we're going to write position and rotation.
We don't change the size of the dynamic item.
If you're implementing that protocol, of course, we might write position and angle on each simulation tick.
So, again, that is two methods where you should be careful about your performance.
One consequence of that is we won't care about any external change to this value after we basically grab the initial state.
So one interesting question is how do you change the size of something after the effect?
We don't change views, items, bodies in the engine, so you have two ways to change the size of an item, remove it from dynamics, and add it again later if you want, or cheat.

Oh I just responded to your email and did not understand your question.
You should be able to do what @Emile Schwarz said. Create the class, set the Super to Label, then click the Interfaces button and choose AnimationKit.ValueAnimator. Then you can copy and paste each method into your navigator/sidebar. You may have two AnimationStep methods at that point, so delete the empty one.
Its just a quick and dirty example of what the ValueAnimator can do, Id have packaged it up as a usable class if I expected people to actually use it for something.
Ah, bad example code. Change If Task <> Nil And Not (Task.Completed Or Task.Cancelled) Then to the simpler If Task <> Nil Then because it’s perfectly safe to cancel a task that is already finished or cancelled.
No, that won’t work because you’re setting Value up to 100, then immediately setting it back down to 0. The second action cancels the first, and since the value hasn’t actually changed yet, nothing actually happens.
Try setting CountingLabel1.Text = "100" first so the animation is avoided and the value updated immediately.

The feature I could leverage the best to make the editing experience easier was IBInspectable properties on types. These allow defining custom fields on types to be edited directly in Interface Builder. These properties, on several key types, allowed me to do all of my page design directly in the graphical interface.
The visual layout of the pages was very straightforward. Each page is its own view controller interface file and simply consists of images and text like any standard view. Every file uses the same
PageViewController class. To support animations was a little tricker. I designed a type called
LinearViewAnimation that I could add to each page as simple objects alongside the view in the interface file. I could make a connection from it to the views I wanted the animation to act on. It had several different inspectable properties:
- Duration – How long the animation should take.
- Delay – How long to wait to start the animation.
- Translation – X and Y values for how far to move the views.
- Zoom – X and Y values for how much to zoom the views (separate X and Y values allowed for distortions).
- Rotation – How much to rotate the views.
- Alpha – How to change the opacity of the views.
- IsRepeated – Whether the animation should be repeated or not when done.
- IsAutoReversed – If the animation should be played backwards at then end.
A separate object can be dropped in for each distinct animation and they are automatically picked up and setup by the
PageViewController class while loading the nib file. That eliminates the need for me to connect them explicitly to the view controller which is especially good so that I can't have the error of forgetting to do so.
The one subtly is that these properties should be set to define how to move the view from its current position to its starting position. That means I am actually designing the animations in reverse. This allows me to design each page for its end state instead of its starting state. This is much better because most pages build in and then stay put. I didn't want a bunch of pages to look blank when opened.
This type did leave me with one major question though: what should I do if I want to animate the same view in multiple ways with different timings? For example, let's look at the following page:
The sheets and hands have to animate up while at the same time the hands need to be shaking back and forth slightly.

In this tutorial, we will focus on the bone-based 2D animation tools provided by the Unity engine. The main idea is to present and teach the fundamentals of 2D animation in order for you to apply it to your own games. In this post, we'll set up the project, define the assets, and do the initial preparations for the animation.
Before we start the tutorial, we would like to thank Chenguang (DragonBonesTeam) for providing us with the game art used to produce this tutorial series.
Who is This Tutorial For?
This tutorial is primarily aimed at two groups of game developers:
- Those who are unfamiliar with Unity at all.
- Those who are familiar with Unity, but not the Unity 2D engine and tools.
We assume that you have some programming skills, so we won't cover the code in depth. In order to follow this tutorial, you will of course need to download Unity.
For a quick start using Unity, follow our previous tutorial that introduces you to the Unity 2D environment and its tools and characteristics. We strongly recommend that you do this if you are not familiar with Unity.
This demo shows the animated dragon we're aiming for:
Launch Unity and create a new project by selecting New Project... from the File menu. The Project Wizard will appear. Now, create a new 2D project, followed by a new folder called
Sprites (inside your Assets directory).
Now that you have the project folder organized, it's time to import the game assets. You can find them in the Assets folder of this tutorial's GitHub repo. (You can just click Download ZIP on the latter page if you're not familiar with GitHub.) Note that this folder includes assets for the whole tutorial series, so there are some that you won't use until later on.
Bone Animation vs Sprite Atlases
Before moving on, compare the following two images:
In the first image, the dragon is divided into several body parts (head, body, arms, and so on). In the second, the ninja is shown in several poses, with a sequence of poses for different actions. This lets you clearly imagine how the avatar will move in your game.
The ninja sprite is what we call a sprite sheet or sprite atlas. This type of sprite was very popular on the classic 2D games, and it's still very common today.
The dragon sprite requires a more recent 2D animation technique, normally called bone-based animation.

A good tip is to enable “Auto Key” so that Spine remembers your bone keyframes automatically.
Once you have saved all the motions, to playback the animation as a loop, click the ‘repeat’ button and then the ‘play’ button. This will show you if you have misplaced bones or anything that isn’t moving naturally. Make changes if necessary, keyframe by keyframe, making sure to save each edit via the keyframe button. View more fine-grained detail of the animation by clicking ‘dope sheet’. Change the speed of playback by editing it in the ‘playback’ area, accessible from the ‘playback’ button.
Satisfied with your animation? Now it’s time to export it. For this, you need a paid license. There are several options to export, and even a built-in texturepacking tool so that you can pack all of your images into one .png and generate an atlas, if you prefer to build sprites.
For my purposes, I saved the animations as a .json file. You can save it in ‘pretty print’ format to make it easier to read and debug.
To use your new animation in your mobile app, you need one of the runtimes built by Esoteric Software. I imported the Corona SDK runtime into my app.
The completed project is available on github. Once the .json file and images are accessible to your main codebase, you can add particle effects and buttons to can attach your animations to a given event (The below code is lua).

However, as any asynchronous system, other things are happening while the animations are working, such as the user clicking and moving the mouse everywhere (which causes a bug on buttons, don’t know how to solve that yet). To create this system, I added a
job function attached to the scene, which can create multiple
jobs and run that in parallel.
job functions receives the duration of the job, the delay to start it, an update function which will perform the animation, and a complete function which is called when the job finished. Moreover, the programmer may stop every job at any time.
At last, I just want to recommend the Affinity Designer, it is a wonderful software for vector drawing, and it save a lot of time with the automatic exporting. I used it together with the Texture Packer and a small script to make the sprite sheet. It was really efficient: I save the document; the Affinity Designer export everything to a specific folder; then I just click export sprite sheet on Texture Packer (I only have to add new sprites if I create new ones); and run the script (I have a console ready to execute it), and done.

Action+ is a feature in Animaker that helps you chain together multiple different actions in a sequence.
To use Action+, click on the icon in the Item Menu.
Click on the add action button
Add the action you want to the character to do next.
Repeat this step for all the actions you want to add into your sequence.
You can check out our In-App Tutorial or the video below for a more detailed guide to using Action+ in Animaker.

Choreography creation/Creating Events/Skeletal animation
Animating an Actor's body is easily as important as animating his or her lips and face. While somebody's expression can tell you a great deal more than their movements, that does not mean that a choreographer can afford to focus too much on the former and neglect the latter. In particular, body animations are visible from a further distance than facial animations, and become the overriding concern when an actor will be delivering their performance a distance from the player's view or in a crowded environment.
In this tutorial, body animation is placed before facial expressions, generic events and lip synching. This is in order to suggest a productive workflow; however, there is nothing to stop you performing the four stages in any order you choose, or in no order, if you find doing so more helpful.
Source's animation technology
As opposed to facial expressions, body animations (Gestures, Blend Gestures or Sequences) are constructed from the pre-existing animations that are compiled into each Actor's model. Any animation can be used in any form—Gesture, Blend Gesture or Sequence—but you will see undesirable results if you stretch that fact too far.
Source provides several animation technologies that will help you produce a more authentic performance:
- Any animation can be layered above any other, including those played by the Actor's AI system, to combine the two movements (Blending). Among other benefits, the system creates very natural motions and let animators create a modular set of basic movements that provide choreographers great flexibility. The 'Sequence' event type can be used to override this behaviour.
- Any animation can be sped up or slowed down at any point to alter the progression of its playback (Timing Tag manipulation), including overall lengthening or shortening. This enables precise synchronisation between dialogue and reusable animations.
- Any animation can have its intensity changed between 100% and 0% at any point (Ramp manipulation). This can be used to reduce the amount of movement in or even hide entirely certain parts of the animation.
Note that for all of this flexibility, animations cannot be created without falling back to dedicated 3D animation tools like XSI.
Types of animation
- Gestures are the most common form of animation and support the full range of animation features, including blending with other Gestures. A Gesture will take control of whatever areas of the model it needs to play.

I started with a base behavior, a single cell that I want to drag around with a spring effect, and the way I defined my behavior is four springs attached to a plane or rectangle and attached to the center of this view.
So I'm going to move these four points to get the spring effect.
Then I need to be able to drag many items, right?
So I'm going to define my high-level drag behavior and I'm going to do the exact same trick for all cells.
Then I need a layout and I'm going to define a flow layout subclass because the basic mode of my layout is just to display a grid.
It only changes when I interact with it.
So I need three classes, a DraggableLayout which is a UIColelctionViewFlowLayout.
I'm going to define a simple API on this layout so I can easily connect that to a gesture recognizer, I can start the interaction with an array of index paths from a point.
I can update that location and I can stop the interaction.
My high-level behavior is going to be quite similar for the API.
I'm going to create a drag behavior with a set of dynamic items and from a point, and a way to change that location.
And my low-level behavior is going to be defined with just one item I want to animate, a point and a way to update the location of this cell.
So let's see how I implemented that.
Let's start with a low-level behavior.
RectangleAttachmentBehavior, I configured that as an item at a given point and then it's just a matter of creating four attachment behavior, so I have this four points, I just create a spring AttachmentBehavior for each point and I add these as children behaviors.
When I want to update the location, I just need to compute again these four points and update the attachment point for my four attachment behaviors.
So that's my first low-level behavior using four predefined attachment behaviors.
The high-level behavior, drag behavior is actually very simple, it's all in this slide.
So what do I need?
I need to pass the dynamic items I want to animate, that point.
I'm going to create attachments, my low-level attachments, RectangleAttachmentBehavior.
I add this as child behaviors and to update the drag location, I'm just going to basically tell my low-level behavior to update to this point.
So that's it for my high-level behavior.
No more layouts.
The interaction code is quite simple actually.
I need to track these index paths.

In this course you will learn the basics about the framework SpriteKit. I going to explain some theory and some practice examples so that you know a lot more about SpriteKit after this course.
The course is structured to help you quickly understand 2 key concepts so that you can start creating your first game straight away without any delay.
After each video you will understand more and more fundamentals about developing games with SpriteKit.
Create your own game to impress your boy friend, girl friend or your kids <3
It's easy to learn with very little pieces of code.
You want to learn to develop own games.
This course is fun :)
Require minimum programming knowledge..
A taste of how to create your mini game quickly with ease.
How to create a game for your iPhone.
Understand key concepts in creating iOS games.
How to create different Scenes in your game.
How to import awesome fonts to your game.
How to create Animation with Sprite.
How to create physical contact between game characters.
How to create behaviours, logic, sounds and game effect.
Task 1: Starter
Task 2: Menu Scene
Task 3: Game Scene
Task 4: Game Effects

In solo game development, you can’t just stick to your strong suit. If you’re a Software Engineer trying out solo game development, being a solid developer will only get you so far; even if you’re using assets made by others, you’ll still need to know how to integrate them into your game tightly.
Animation is a great example. Imagine a character model has animations for walking, running, standing, talking, interacting, and more. In that case, you will still need to define how a character object triggers and transitions between these animations. These animations might also dictate what your object does; for example, an enemy that punches characters might want to deal damage at the precise moment the model’s arms are fully extended.
Today, we’ll discuss the essential concepts of using Animation in Unity. We’ll also go over a few examples using the incredibly cute Modular Animal Knights PBR asset pack from the Unity Asset Store. A free version that includes only the Dog is available here as well.
An Animation Clip (Animation for short,
AnimationClip in code) is an asset that describes a series of keyframes for each property on a Game Object over time.
In other words, an Animation Clip asset describes, for a given Object, the change over time of any number of properties on that object. An Animation Clip can control any property on a Game Object or recursively accessible from a Game Object or any child object.
In addition to an Animation Clip specifying properties on a Game Object, a clip can control Animation Avatar properties. An Animation Avatar is an asset that defines the relationship between a standard “skeleton” set of transforms (head, chest, leg, etc.) to a specific model. See the Character Animation tutorial on Unity Learn for more details.
For example, in the above screenshot, the “Dog Knight” model comes with an Avatar asset that defines the relationships between . The animations included in the asset pack control the avatar transforms. Prefabs included in the asset pack will point to an…

[ Silence ]
[ Applause ]
Welcome to this WWDC session on Advanced Techniques with UIKit Dynamics.
We have a lot of content for you today, many lines of code.
So let's get started.
We're going to start with a very quick recap of dynamics, architecture, and we're going to explore more of this "combining behaviors" idea.
And we're going to talk briefly again about dynamic items, custom dynamic items.
And we have a quick example about collection view and dynamics.
And we will end with great demo and architecture about using view controllers with dynamics.
So UIKit Dynamics.
It's a physics inspired animation and interaction system.
Made to be composable, combinable, reusable.
We try to use Dynamics in a way which is declarative.
You tell us what the intent of the interaction is and we will try to combine the effect of all new behaviors to animate things on screen.
Let me stress that this does not, in anyway, replace what we have to day with Core Animation, UIView animation, or motion effects.
It is just a new tool for rich, real-world like interactions.
So the base Dynamics architecture, we have this DynamicAnimator which gives us this context in which we associate various behaviors and we associate dynamic items which are usually views or collection view layout attributes.
And the key thing here is, an item might be part of different behaviors and we're going to combine all these effects.
So let's talk about UIDynamicAnimator.
So its main job is to track behaviors and animated items.
And it wraps the underlying physics engine we run for you.
What's interesting is, we try to actually optimize that engine.
So if we detect that the system is at rest, we just stop.
If you change anything like changing the parameter on one of your behaviors, we start the system again.
And you can actually be notified.
We have a UIDynamicAnimatorDelegate, so you can implement methods so you can know if we are about to pause or resume that system.
You can use a DynamicAnimator in three modes basically, with views which is the common case.
In collection views collection view layout exactly, and you can implement your own dynamic item to participate in dynamics.
So let's talk about combining behaviors.
Combining behaviors is interesting: the underlying model physics is in itself quite good about combining things, combine two forces and you get a force.
And we build on that, we have this base class UIDynamicBehavior that you can subclass.

The 3D model is quite basic for now, it was built using Blender. I had not used Blender since high school so it was a complete re-discovery; I especially like the Edit mode capabilities when modeling. Yet, there are a few caveats when exporting a Collada file for SceneKit: the shading and normals have to be correctly set up before exporting, as SceneKit won't do any kind of normals reconstruction/interpolation.
I might add the possibility to choose from a set of lanterns, or to generate random lamps using a simple grammar with building blocks. This will be done later, as I first want to focus on having a clean and coherent mood for the scene.
To add a bit of context to the scene, I added rocks and a few blades of grass. The rocks are basic polyhedra edited in Blender, whereas the grass is made of triangular-based shapes.
In order to animate the grass, one could use a physical simulation with wind, as SceneKit includes a physics engine, or import a rigged animation. But the simplest way is to modify the position of the vertices in the vertex shader. SceneKit implements its own private rendering pipeline, but it fortunately allows us to inject code at four given entry points in the shaders attached to any geometry:
For each of these modifiers, SceneKit provides a few useful values (position, normal, texture coordinates, transformation matrices,... ) and one can also set uniform variables using the standard key-value observer pattern in Swift/Objective-C.
Here, we want to move the vertices along time, depending on their height above the ground. We can compute an horizontal offset in GLSL code and inject the code:
grass.shaderModifiers = [ SCNShaderModifierEntryPointGeometry: "float offset = 0.375 * sin(1.2 * u_time) * pow(max(0.0,_geometry.position.y-1.2),2);\n" + "_geometry.position.x += offset/1.414213;\n" + "_geometry.position.z -= offset/1.414213;" ]
And that's all for the first log! Since then I've had the time to add lighting animations and particles effects, so this is one of the topics I'll cover in the next article, (hopefully) next week. Below is a small animated preview, enjoy!
And please let me know what you think of my project!