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

Backgrounds

Contents

  • What are Backgrounds?
  • How do Backgrounds scroll? (Parallax Scrolling)
  • How To: Importing Backgrounds
  • Animated Backgrounds
  • Auto-Scrolling
  • Repeating Backgrounds
  • Foregrounds
  • Showing Backgrounds in the Scene Designer

 

What are Backgrounds?

Backgrounds are large images that usually scroll alongside a scene, either entirely behind or in front of a scene.

Backgrounds can visually enhance a game and provide the illusion of depth. Some games even draw backgrounds in front of a screen for visual flair (like in the video above) or to obscure part of the screen.


How do Backgrounds scroll? (Parallax Scrolling)

Put simply, backgrounds scroll at the same pace that you progress overall inside a scene, where "progress" is defined by the location of the Camera. This is commonly known as Parallax Scrolling.

If you’re halfway through a scene, the background will be scrolled halfway through.

background-scrolling-example

Likewise, if you're at the end of the scene, the background will be scrolled through to the end.

background-scrolling-scene-example

To think about this another way, since backgrounds are almost always larger than the screen size, they’ll scroll at a slower-pace than the main layers, making them feel like they’re in the distance.

In this video, notice how things in the "foreground" scroll by quickly while things in the "background" (hills)  scroll by slowly.

Intuitively, this makes sense. If you look outside your car's window, the close-by buildings you drive by will fly by quickly. But the mountains in the distance will move relatively slowly because they are far away.

Bottom Line: You don't need to do anything special to make Parallax Scrolling work in Stencyl, but it helps to understand how this kind of scrolling works.

 

How To: Importing Backgrounds

Importing backgrounds works much like importing any other kind of graphic into Stencyl.

1) Create a new Background.

stencyl-create-background

2) Inside the Background Editor, Click the dotted box to choose an image or drag and drop the image in.

stencyl-create-background-frame

3) Once you've done that, click the Attach to Scene button at top-right corner to attach this background to a Scene. That's it!

stencyl-add-background-to-scene  stencyl-background-in-scene
 

Note: Avoid making a background that’s smaller than the screen size. The one exception is if you’re creating a repeating background, in which case, the image will tile-itself until it fills out the screen.


Animated Backgrounds

You may notice that you can import multiple frames into a background and edit each frame's individual duration. Doing this will cause the background to animate.

Tip: Avoid creating animated backgrounds for mobile games, as it can quickly exhaust the limited atlas space you already have!

 

Auto-Scrolling

Some games call for a background that automatically scrolls, regardless of the player’s progression through a scene. Auto-scrolling can impart the sense of constant motion.

This Stencyl game demonstrates auto-scrolling at its best.

Setting a background to auto-scroll is simple.

stencyl-background-scroll-speed

The values don’t hold much meaning in themselves (pixels per sub-frame). Just experiment until you get a value that works for your game.

Note that auto-scrolling backgrounds do not parallax scroll - they're already scrolling!

Note: Don’t confuse auto-scrolling backgrounds with the notion of an auto-scrolling level in Super Mario Bros, the kind where you’re forced to stay on screen and complete the level at the set pace. We cover this topic inside our Camera article.

 

Repeating Backgrounds

What if your background is meant to be a repeating pattern like the following?

stencyl-repeating-background

Mark the Repeat Background checkbox if this is the case.

stencyl-repeat-background-checkbox

Repeating Backgrounds can auto-scroll, but they do not parallax scroll. In other words, they scroll directly alongside the main layers.

 

Foregrounds

Foregrounds are Backgrounds that draw in front of everything else.

To designate a Background as a Foreground, just add it to the Foregrounds list inside the Backgrounds page of the Scene Designer.

stencyl-foreground

Note: Since Foregrounds draw in front of everything else, ensure that they are at least partly transparent, or else the Foreground will block out everything else.

 

Showing Backgrounds in the Scene Designer

These buttons let you toggle Background and Foreground drawing in the Scene Designer. They're located at the top-right.

stencyl-scene-designer-show-background-button


Summary

  • Backgrounds are large images that scroll behind or in front of the screen.
  • Backgrounds are like mountains in real life - they scroll by slower than what’s happening right in front of you.
  • Use auto-scrolling to make a game feel like it’s in constant motion.

 

Challenge: Endless Game

Endless games such as Canabalt and Jetpack Joyride are very popular these days.

Even Stencyl has its own variation on this theme in the form of Super Belly Boarder, a winter-themed take on an endless game.

stencyl-background-challenge-game-pic

Create a simple endless game of your own, using an auto-scrolling background to impart the illusion of constant motion.

Think carefully about how you’d make the game truly endless and random in nature. In other words, don’t make an enormous level - that’s the wrong way to do it.



Last Updated: 2012-05-13 by Ceric

14339 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!
2 Comments
dagudino
what I did was upload the background as an actor instead, and resize it then as an actor in the scene
0 4 months, 2 weeks ago
jpeterson
came here to look for an auto-resize background sort of thing but ended up just resizing my background to fit screen, any way to still do that?
1 5 months, 1 week 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.