Stencyl Essentials - Sample Chapter
Stencyl Essentials - Sample Chapter
"Community
Experience
Distilled"
C o m m u n i t y
Richard Sneyd
Stencyl Essentials
Stencyl Essentials
D i s t i l l e d
Stencyl Essentials
Build beautiful, unique, cross-platform games rapidly with the
free Stencyl 2D game engine and toolset
E x p e r i e n c e
Richard Sneyd
Stencyl Essentials
The world of game development has been in a state of flux for the past few years. New
technology, as well as new development tools and frameworks, has diversified the games
industry and opened up the field to those who may not otherwise have been in a position
to realize and publish their game concepts.
Stencyl is one such innovation. Developed from the ground up by founder Jonathan
Chung, to be as accessible as possible to as many people as possible, yet it still retains the
awesome power necessary for professional-level developers. Stencyl makes it possible
for anyone with a great idea and the right motivation to develop their own games, from
concept to market.
Stencyl Essentials has been written to get you up and running with Stencyl faster than
with any other book, as it has been written in terse, yet lucid prose with a no-nonsense
style, enabling you to get to grips with Stencyl in a fun, yet fast-paced way. This book is
centered around a project, which has been designed to reinforce all of the key learning
objectives. You will be guided through the process of building a game prototype, which
is based on a successful, published game called Mudslide Cowboy (CyberMyth Games).
By the end of this book, you will be competent in the use of all of Stencyl's most
important features, and quite prepared to start working on your own game projects.
Chapter 7, Complex Behaviors and Code, digs deep into the incredible power of Stencyl's
visual programming system, showing you how to harness it at a more advanced level.
Chapter 8, Adding Sound Effects and Music, explains how Stencyl handles audio, and
then guides you through the process of importing sound fi les, configuring them, and
playing them in-game.
Chapter 9, Adding HUD Elements, shows how we can use actors in a special way to
create animated elements of our heads-up display.
Chapter 10, Adding Menus and Buttons, guides you through the process of creating a
Start screen and adding functional buttons to it.
Chapter 11, Scoring and Game Rules, helps you implement a game rule, based around
the collection of gold coins, that will aid us in measuring success or failure during
play sessions.
Chapter 12, Publishing and Monetization, gives us a clear overview of the principal
publishing and monetization available to game developers in Stencyl.
[ 25 ]
Click on it, and you will be presented with the following window:
[ 26 ]
Chapter 3
[ 27 ]
This is the Background Editor. To the right, you will see a pane with various
parameters that can be used to create parallax scrolling effects. To the left, we have
a button that can be used to add new frames to our background. We can add more
than one frame if we wish to animate the background, though excessive use of
this feature is likely to adversely impact memory and performance, especially on
mobile targets. Click on the Add Frame button, and you will be presented with the
following window:
From left to right, at the top of the window, the options we are presented with are
as follows:
Choose Image: This option is used to select an image with a file browser
Paste from Clipboard: This option is used to paste bitmap data from the
clipboard into the frame
Scale: This option is used to choose the scale at which to import the image
Resize Method: This option is used to choose your preferred resizing algorithm
[ 28 ]
Chapter 3
Before clicking on the Choose Image button, we must first ensure that we have
selected the correct Scale and Resize Method (or algorithm), and configure a few
other settings. Follow these steps:
1. First, set the Resize Method to Bicubic if this is not already the setting.
Our game graphics have all been created at 4X scale, the highest resolution
available. This caters for all targets, irrespective of screen dimensions or
resolution. Stencyl will generate the lower resolution versions of the images
(1X, 2X) automatically from the 4X version we provide.
2. Select 4X from the drop-down menu, then click on the Choose Image button.
This will open a file explorer.
3. Simply navigate to the directory where you extracted the contents of the
game assets ZIP file we downloaded in the previous chapter. Navigate to
Game Assets | Graphics | Backgrounds and import Grass Background.
png, as shown in the following screenshot:
[ 29 ]
Click on the Add button at the bottom-right corner of the window, and you will have
imported your first static background into Stencyl. Congratulations! Next, we want
to configure our parallax scrolling settings for the background:
1. You can tick the Repeat Background checkbox seen in the following screenshot:
Home Screen Background: This background image uses the exact same
settings as before
Plain Wood Background: This background image uses the exact same
settings as before
[ 30 ]
Chapter 3
Well done! We have successfully imported and configured all of the background
images needed to build our prototype game. Now we just need to import our first
tileset, and we can start building our own 2D game worlds!
[ 31 ]
Click on Choose Image, and the file browser will open, as it did during the
importing process for our backgrounds. Navigate to the game assets folder as before.
The tileset can be found in the Game Assets/Graphics/Tilesets/green grass
tileset.png directory. If successful, you should see the tileset fill the window like
the following screenshot:
When working in Stencyl, we always see the 1X scale graphics, as this is the default
resolution for desktop targets (Windows, Mac, and Linux). The higher resolution
graphics are only used when we test or run the game. Which particular resolution
is utilized at runtime depends on the platform and device being targeted, screen
dimensions, and so on. Now click on an individual tile to edit its settings. The two
most important settings to be configured are as follows:
[ 32 ]
Chapter 3
Frames: By default, all the tiles have just one framemost tiles are static.
If you wish to animate a tile (water, lava, and so on), you can import
additional frames and set their duration in milliseconds, as shown in
the following screenshot:
If you click and drag the tilesheet from one tile location to
another, you can make a rectangular selection of multiple tiles.
This can be timesaving if you wish to set the same collision
shape for multiple tiles. Try it.
Each tile in the set has its own collision bound, highlighted in the Collision Bounds
pane to the right. Be sure to match the Collision Bounds pane to the visible part of
the tile as closely as possible, using the various shapes available under Collision
Bounds to the right of the screen. You can create custom shapes, if you want to be
very precise, by clicking on the plus (+) button at the top left of the Collision Bounds
window, as shown in the preceding screenshot. When you are satisfied, save your
progress, and click on the close (x) icon on the Tileset tab, which is to the right of the
Dashboard tab toward the top of the screen, to close out the editor for now.
[ 33 ]
Summary
In this chapter, we learned the processes involved in importing two of the most
significant graphical resource types in Stencyl: Backgrounds and Tilesets, which
are used to sculpt the ludic (pertaining to games and play) and aesthetic (pertaining
to beauty) space of our games. We configured parallax scrolling settings for our
backgrounds, and we learned how to cater for all resolutions by importing at
4X scale and allowing Stencyl to generate the lower resolutions using a bicubic
algorithm. In the next chapter, we'll learn how to use these newly imported game
assets to start building out the space of our game levels!
[ 34 ]
www.PacktPub.com
Stay Connected: