Username or E-mail
Password (Forgot?)
New? Sign Up
Join or Sign In
Forums Stencylpedia Stencyl TV Translations Go Pro - Plans & Pricing Download Stencyl


Switch to Book Layout

1: Getting Started

  • Getting Started
  • Crash Course
  • Crash Course 2
  • StencylForge

2: Building Logic

  • What is a Behavior?
  • Creating a Behavior
  • Attributes
  • Game Attributes
  • Attribute Types
  • Events
  • Our Behaviors

3: Actors

  • What are Actors?
  • Animations
  • Motion & Forces
  • Physics
  • Controls
  • Collisions & Groups
  • Killing vs. Recycling
  • Tweening
  • Effects
  • Chapter 3 Challenge

4: Scenes

  • Scene Basics
  • The Camera
  • Tilesets
  • Regions
  • Drawing Text & HUDs
  • Changing Scenes
  • Music, Sounds & Channels
  • Backgrounds
  • Customizing Actors
  • Chapter 4 Challenge

5: Game Mechanics

  • Saving
  • Pausing
  • 3rd Party Services
  • Web Requests

6: Advanced Topics

  • Get/Set Attributes
  • Custom Events
  • Blending Modes
  • Lists
  • Custom Blocks
  • Continuous Collisions

7: Testing & Tuning

  • Testing Games
  • Optimizing Performance 1
  • Optimizing Performance 2

8: The Last 10%

  • Flash Publishing
  • Standalone Apps
  • iOS App Store
  • Chrome Store
  • Making Money

M1: Mobile - Intro

  • Getting Started
  • Testing on your Device
  • Flash -> iOS Guide

M2: Mobile - Basics

  • Atlases
  • Drawing Text
  • Retina Display
  • Accelerometer
  • Joystick
  • Universal Games

M3: Mobile - Services

  • iAds
  • Game Center
  • In-App Purchases

M4: Mobile - Publishing

  • Debugging
  • Publishing to the App Store
  • Optimizing Performance
  • Promoting your Game

A: Troubleshooting

  • Showstoppers
  • General FAQ
  • iOS FAQ
  • The 90% Memory Warning
  • Recovering Broken Games
  • Can't Export to SWF
  • Reloading Documents
  • Generating Logs
  • Flash Security Settings
  • How to Report Bugs

B: How-To Guides

  • Importing Assets
  • Scene Designer
  • Code Mode
  • Font Editor
  • Pencyl (Image Editor)
  • Tile Editor (Shapes)
  • Game Cleaner

C: Reference

  • Glossary
  • Block Reference
  • Useful Shortcuts
  • Stencyl API

D: Resources

  • Stencyl TV
  • Abigayl's Guides
  • Giving Critiques
  • Creating Extensions
  • Translating Stencyl
  • Credits

3.0 Drafts (In Progress)

  • What's New in Stencyl 3.0?
  • Setup (Android)
  • Setup (Desktop)
  • Setup (iOS) - Concepts
  • Setup (iOS) - Mac
  • Setup (iOS) - Windows
  • Testing iOS on Windows
  • iOS Troubleshooter

  • Mobile App Scaling
  • Full Screen Mode
  • Simple Physics
  • Backgrounding an App

  • iOS App Store
  • Mac App Store
  • Windows Store
  • Google Play
  • HTML5

  • Android Ads
  • Android Purchases (WIP)
  • 4" Form Factor (iPhone 5)
  • Mobile Input
  • Mobile Features

  • Extending the Engine
  • iOS / Android Extensions
  • Developing the Official Extensions
  • Developing the Engine

  • iAds (Revised)
  • Game Center (Revised)
  • iOS Purchases (Revised)
  • Atlases (Revised)
  • Drawing Text (Revised)
  • Joystick (Revised)
  • Accelerometer (Revised)
  • Sounds (Revised, WIP)
  • Debugging (Revised, WIP)
  • iOS Performance (Revised)
Level: Beginner

Animations

Contents

  • What are Animations?
  • What does an Animation consist of?
    • Frames
    • Collision Bounds
  • Importing Animations
  • Switching Animations
  • Controlling Playback
  • More Animations vs. More Actor Types: The Zelda Dilemma
  • Gotchas

 

What are Animations?

Animations bring actors to life. They represent the visuals of an actor, its collision bounds and the notion of being in a certain "state" - such as running, walking and jumping.


megaman-running-animation
 

What are examples of animation states?

  • A platformer hero's states (Stand, Walk, Run, Jump)
  • Treaure Chest (Opened, Not Opened)
  • Destructible Objects that "break" when hit by something else (Broken, Not Broken)

treasure-chest-animation

 

What does an Animation Consist of?

Each Animation state consists of 2 separate parts:

  • Frames (how it looks)
  • Collision Data (the collision shape )


Frames

Frames are like pages in a flipbook. Each frame represents a a different image or "page" in the book. When these images change quickly over a period of time, the result is an animation.


To bring this back to games...

This actor's swinging his sword to the right.

stencyl-animation-frames

 

Importing Frames

We cover the how-to part of importing later in this article.


Frame Duration

Every frame can be given a different duration (in milliseconds). Just double-click the box for it.

stencyl-frame-duration

Notes: The minimum duration is 10ms. To edit multiple frame durations at a time, select multiple frames (using SHIFT or CTRL/Command) and click Edit Frame.


Looping

Frames can be set to loop or play once.

animation-looping

 

Origin Point

An Animation can also have a designated origin point. The origin point is used to determine the point by which an actor rotates or scales. By default, this is set to the center point.

image-origin-point

Note: Origin Points are not implemented for mobile games. They will be supported for mobile games starting in Stencyl 2.5.


Atlas (Mobile-Only)

The Atlas field is specific to mobile games. View our Atlases article for details.


Collision Bounds

As their name suggests, Collision Bounds determine the physical shape(s) that an an actor assumes in a particular Animation state.

To define Collision Bounds, flip to the "Collisions" page of the Actor Editor. There, you will be able to edit your Animation's Collision Bounds on a per-animation basis.

collision-bounds

Note: For your convenience, we default to a box that matches the size of the animation itself.

 

Tip: You cannot set collision bounds per-frame, yet. This can be worked around by defining a new animation per-frame and switching animations.

 

Importing Animations

Now that you understand animations, let's go over the import process. You can import animations in one of several ways.

  • Pick an image.
  • Drag and Drop.

 

Method 1: Pick an Image

(Assuming you've got an Actor open in the Actor Editor...)

1) Click on "Click here to add frame" under the Frames pane.

stencyl-choose-image

2) You'll now see this dialog. Click the "Choose an Image..." button and pick out the desired image. Want to follow this exact example? Use this image.

stencyl-import-images

3) Now, configure columns and rows to break up the image, as appropriate depending on how many cells it has in those directions.

stencyl-import-frames

4) If applicable, enter in values for the border and spacing fields. The majority of images do NOT need to worry about these fields.

5) Click Add. That's it!

After importing frames, you can give the Animation a name, alter frame durations and other properties we described above.

Note: Mobile games have to import images at twice their size in order to accomodate the Retina Display. See our Retina Display article for details.

 

Method 2: Drag and Drop

You can drag and drop an image into Stencyl while the Actor Editor is open. Doing this will bring up the dialog you see in method 1.

Notes

- Dragging in an animated GIF will bypass the dialog and immediately import the frames.

- Dragging in an image to the Dashboard or an editor that is not the Actor Editor will have varying effects, none which will import a new animation for the current Actor. Expected but worth noting.

 

Switching Animations

Notes

For all of these blocks, the "animation" blank takes in an Animation attribute or value. You can convert plain text into an Animation value using the "as animation" block.

stencyl-switch-animation-block

All of these blocks are found under Actor > Drawing.


Switch Animation

stencyl-design-mode-switch-animation-block

Note: As stated right above, if you want to type in the name of the Animation directly, use the "as animation" block.

stencyl-switch-animation-block

 

What's the current Animation?

stencyl-design-mode-get-current-animation-block

 

Is the current Animation still playing?

Sometimes, it's useful to check if the current animation is still playing, particularly if the animation does not loop, and you want to detect if it has finished playing through.

stencyl-design-mode-animation-playing-block


Controlling Playback

Switch to Frame

This block lets you skip around or reset an animation to its starting frame.

stencyl-design-mode-switch-frame-block

Note: Frame indices are displayed in the gray boxes and start from 0. Switching to an invalid frame leads to nothing happening.

 

Current Frame Index

stencyl-design-mode-get-current-frame-block

 

Total Frame Count

stencyl-design-mode-get-frame-count-block

 

More Animations or More Actors?

There is no limit to the number of animations an actor may have. However, it's best to consider when it's appropriate to go with more animations or whether it's better to create a brand new actor.

 

The Zelda Dilemma

The Zelda Dilemma is a classic game design problem you run into when making an Adventure game and decide how you want to create your Hero character.

So suppose that we start with just the basic animations.

  • Walk
    • Left
    • Right
    • Up
    • Down

Not to bad so far. But Link holds a sword! So we have to add 2 more sets of animations, one for holding the sword and one for slashing it.

  • Walk
    • Left
    • Right
    • Up
    • Down
  • Walk + Sword
    • Left
    • Right
    • Up
    • Down
  • Walk + Slashing Sword
    • Left
    • Right
    • Up
    • Down

But wait, there's more! Link changes swords throughought the game. He can hold the plain sword, the Master Sword and the Golden Sword, and they all look different! That would triple the animation count.

zelda-link-animation

And what about the Bow and Arrow, holding a shield and... you get the picture.

 

The Bottom Line

In cases like these, it's better to create a new actor rather than add more animations. This is particularly applicable when an actor equips items that slightly alter the appearance and could be accurately and convincingly drawn separately.

zelda-link-sword-animation
(From Zelda - the sword is a separate actor)
 

There are other benefits to having different actors.

  • Easier to define collision bounds, particularly for weapons.
  • Confine extra behaviors to the separate actor, rather than creating 1 monolithic actor with everything.


The bottom line is that there's no silver bullet and no simple rule. You simply have to create and recognize when things are going the wrong way. Hopefully this example shines light on a case where it's thoroughly clear that an all animations approach is flawed.

 

Gotchas

It's best if all animations are the same size.

It may be necessary in some cases to ensure that all animations of an actor are equal in size. Making animations different sizes, for the same actor, could have a negative impact, especially if the origin point is different in each animation.

Two common scenarios are:

  • The actor magically jumps to a slightly off-center location when you switch animations.
  • The actor's collisions mess up because the new animation has the collision bounds located in a different part of the animation.
Note: This gotcha has been a pain point for some. We're working on addressing this point for Stencyl 2.x.

 

Animations, Blocks & Attributes

Note that when using the "switch animation" block, you cannot type text directly into the blank. Instead, you have to wrap that text inside an "as animation" block like the following.

stencyl-design-mode-as-animation-casting-block

Reminder: All animation-related blocks are located under Actor > Draw.

 

Actors with No Animations

Actors with no animations at all may crash the game. We'll address this in a future version of Stencyl. Note that this is different from an Actor with a single blank (0 frame) animation, which will work just fine.


 

Summary

  • Animations are states, such as standing, walking and running.
  • Animations consist of frames (how it looks) and collision bounds.
  • Exercise good judgement in deciding whether to go with an actor with many animations versus several actors with fewer animations.

 

Challenge: Equipment for an Adventure Game

We talked about the "Zelda Dilemma" above. Now's your chance to see this for yourself and do things the right way.

Create a simple walkaround demo in which the character can equip different items that show up in that character. Do this the right way, by making those items each their own actors.

zelda-link-animation-frames

 

 



Last Updated: 2012-05-13 by Ceric

26768 have read this article
Disclaimer: The Stencyl Team does not actively monitor comments on articles. If you're seeking help for your game, please ask a question on the forums. Thanks!
9 Comments
rainvillain
This was a great tutorial but honestly this challenge is too much for me right now. Should I be worried?
0 3 months, 3 weeks ago
wilycodger
Let's say your character has 3 items, and pressing "Space" cycles between them. How/where do you keep track of which item to create next?
0 4 months, 1 week ago
etfonehome
Nevermind guys, there's a little plus button at the bottom in the column where it holds the states.

0 7 months, 2 days ago
etfonehome
How do you add another state/animation?
0 7 months, 2 days ago
Lingesh7
love d description bt i was wondering wether to use vector/raster graphics (between adobe illustrator and adobe fireworks which is better for designing actors)
0 7 months, 4 weeks ago
BlueSideWind
how do you make a "Slashing Animation" and trigger?
0 8 months, 1 week ago
SomeOnesBody
It would be helpful to know where to find good sprites for the challenge...
0 10 months, 3 weeks ago
Blackalokalypse
i think the concept of giving seperate components their own "actorship" would solve the problem with out having to make layers, as stated in the "breakdown"
0 1 year, 3 weeks ago
BossFight
Is there a way to actually make a layered actor, like in the Zelda example? Or would we have to make (in the Zelda example) 12 x actors with their animations?
0 1 year, 1 month ago



Commenting Guidelines

Sign In to Comment

Make Games

  • What is Stencyl?
  • Roadmap
  • Pricing

Play

  • Arcade
  • Showcase

Community

  • Forums
  • Chat
  • Translations

Help

  • Stencylpedia
  • Stencyl TV

About Us

  • Blog
  • Contact Us
  • Press
  • Privacy
Follow Stencyl on Twitter



© 2013 Stencyl, LLC.