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

Tweening

Contents

  • What is Tweening?
  • Easing
  • Uses for Tweening
  • Gotchas
  • Tweening and Physics
  • Additional Reading


What is Tweening?

Tweens. We’re not talking about pre-teens.

Instead, we’re talking about a powerful ability to bring numerical properties of actors to a destination value over time.

Tweens apply to the following properties.

  • X,Y Position
  • Angle
  • Scale (Size)
  • Opacity (Fading)
How To Tween

All Tweens are initiated using blocks under the Actor > Tweening category.

 

Easing

You may wonder what the final dropdown in each tweening block is all about. We call this the Easing Function, or Easing for short.

Easing adds “elasticity” to the tweening effect in different ways that are best experienced in a live demo. Without Easing, the tweening effects would feel flat and boring.

(View the Demo)

 

Uses for Tweening

Use tweens to add visual flair and polish to your game. How so?

  • Slide buttons off the screen when exiting a menu.
  • Grow a button when your mouse rolls over it.
  • Rotate an object to provide visual affordance or flair.
  • Fade out elements that are inactive or not meant to be touched.

Tweens can make all the difference between a game that feels polished and one that is functional but feels raw.

Next time you play a game, observe where tweens are used. You’ll be surprised to see how pervasive they are!

 

Gotchas

Falling Short

On occasion, you may notice that a tween falls a little short of its “destination.”

This is particularly noticeable when rotating an actor (by say, 90 degrees) and expecting it to finish up at the target value. Due to timing imprecision, this is not guaranteed. We’ll fix this in a future version of Stencyl.

We encourage you to employ a workaround in which you manually set the value in the future.


 

Avoid 0 second durations.

The other gotcha is trying to tween with a 0 second duration. Avoid doing this if possible and use a small, positive value instead such as 0.01 seconds.


Scaling sometimes doesn’t scale up the collision bounds.

On iOS or if you specify an Actor to not auto-scale its collision bounds, you will observe that scaling an Actor up or down will, as expected, not change its collision bounds accordingly.


Tweening and Physics

When sliding, rotating or scaling actors, do not expect the physics to act ultra-reliably during this time.

For example, if you are sliding an actor to the right, and it slams into a box, it may sail past the box instead. Why? Because tweening is directly setting the position (or rotation) of the actor continually.

If accurate physics are desired, avoid using tweens and use conventional methods instead: setting the actor’s velocity or angular velocity, or using forces to push the actor or twist it.

 

Further Reading

One of our veterans has created a slideshow form demo to follow for further reading.

View it on Kongregate!

 

Summary

  • Tweens let you apply gradual changes to an Actor’s property over time.
  • Tweens are not 100% accurate and do not guarantee arrival at the exact final value.
  • Avoid tweening with a 0 second duration. Use a small value like 0.01 instead.
  • Physics becomes inaccurate (it works but is like directly setting position) when using tweening to move an Actor. Use forces or velocity setting instead.


Last Updated: 2012-04-07 by Jon

10432 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!
0 Comments
Be the first to make a comment!



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.