Welcome to Stencyl — an exciting and fun game development tool used by many professional and amateur game developers around the world.
By the end of this book, we will know all the skills required to develop a product that exhibits all the features expected in a professionally-developed computer game.
However, before we start to create our game, we're going to learn about the Stencyl toolkit, install Stencyl, and test that everything is working as required, then experiment with some of the sample games that have been provided with the installation.
In this chapter we will learn the following:
How Stencyl works
How we'll learn to use Stencyl
Why Stencyl is a great development tool
Platforms that Stencyl runs on
What makes Stencyl different
Successful games created with Stencyl
Using the free version of Stencyl
Installing Stencyl and testing the setup
If you have purchased this book, then you may already have an idea of what Stencyl is and how it works.
However, if you are browsing online or standing in a bookstore flicking through the pages of this book, then you might want to know that Stencyl is a no-coding toolkit for creating 2D video games that will run on many different mobile and desktop devices.
Scenes, or levels, within a game are created using Stencyl's drag-and-drop Scene Designer. The screenshot below shows the Scene Designer being used to modify one of the levels in the game that we'll be creating:

Tip
Downloading the color images of this book
We also provide you a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from: http://www.packtpub.com/sites/default/files/downloads/5961OT_ColoredImages.pdf
The instructions or logic for the gameplay can be created using Stencyl's Gameplay Designer— a clever system that utilizes building blocks which snap together to create a series of instructions that are used by the objects in our game. An example of some instructions being created in the Gameplay Designer is shown in the following screenshot:

All that is needed to follow the tutorials in this book are a desktop computer—Microsoft Windows, Mac OS X, or Linux will do just fine, along with the free version of Stencyl that can be downloaded from www.stencyl.com. The free version of Stencyl can be used to develop and publish Flash and HTML5 games, and it can also be used to develop and test games for desktop computers and mobile devices. If you want to publish games for platforms other than Flash and HTML5, then you'll need to pay for an annual subscription to Stencyl in order to access the additional publishing features.
A great way to learn to use a tool such as Stencyl is to complete a practical project, and over the course of this book, we will develop a game from a blank screen right through to completion, learning all the important features of Stencyl along the way.
The game will start in a very basic form and as we progress, we will use the tools within Stencyl to add features to our game until we have a final product that demonstrates many of the characteristics that a professional game should exhibit.
Later in this chapter, we'll install Stencyl and run some test games to ensure that everything is working properly. Then, in Chapter 2, Let's Make a Game!, we'll jump straight in and create a game with a character that we can control as it runs and jumps across a scrolling jungle scene and interacts with an interesting environment.
We're going to experience some amazing results very quickly, so the learning process is going to be fast paced and fun!
The following screenshot was captured while developing the game in Chapter 2, Let's Make a Game!, so it can be seen how quickly we will be progressing through the development of our game.

Stencyl is a ready-to-use, complete, game development studio that can be used by anyone from beginners to game development experts to create professional-quality games; there is no requirement to purchase or install additional software. The Stencyl game development process avoids the repetitive, complicated requirements of writing hundreds of lines of computer code, and gets you started with the creation of your games without being distracted by the intricate details that traditional computer programming languages require.
If you have an idea for a game, Stencyl will enable you to rapidly create a working prototype, so that you can quickly progress to creating a completed game using the great features that come built into the Stencyl toolkit, including:
We'll be learning how to use all these features to enable us to quickly build our video game.
Games can be created without writing a single line of computer code, by using Stencyl's drag-and-drop Gameplay Designer. Its clever system of building sequences of commands using specially designed instruction blocks means that we can only create instructions that make sense to the computer.
If you have ever tried writing computer games using a language such as Apple's Objective-C or Adobe's ActionScript, you probably know how frustrating it can be to ensure that every bracket, period, and special symbol appears in exactly the right place. That's a problem of the past with Stencyl!
One of the many great features of Stencyl is StencylForge — a ready-built repository of game resources that can be used for downloading graphics, audio, gameplay rules (known as Behaviors in Stencyl), and utilities. You can also upload your own resources to share with others.

StencylForge is a remarkable asset to the Stencyl community, and it's one of the exciting features of Stencyl that we'll be learning to use while we develop our game.
In addition to being able to share resources using StencylForge, there is a great community of helpful Stencyl users for both beginner and experienced users at community.stencyl.com.
The Stencyl game development toolkit can be installed on the following desktop computer platforms:
Microsoft Windows (XP, Windows Vista, Windows 7, and Windows 8)
Mac OS X
Linux
The installation process for each of the above platforms is detailed later in this chapter.
When we talk about target platforms, we mean the devices that our game can run on.
Games created with Stencyl can be played on most common platforms including web browsers, Microsoft Windows, Mac OS X and iOS devices (for example, iPhone and iPad), Android, and Linux. The main issues that we need to think about, when it comes to the target platform, are the screen size of the game and how our game will be controlled (that is, keyboard, mouse, or touch). Stencyl does all the hard work for you!
Currently, at the time of publication, Stencyl can target the following platforms:
Apple mobile devices running iOS Version 4.1 and above, including:
iPod touch
iPad
iPhone
Google Android devices running Android Version 2.2 and above, including:
Phones
Tablets
HTML5 web browsers:
Many web browsers and devices that support the HTML5 web standard
Microsoft Windows desktop PCs and laptops:
Windows XP and above
Mac desktop operating systems:
Mac OS X
Linux desktops:
Ubuntu distributions recommended
If you need to target a specific device, it is important to ensure that it is supported. So, check the Stencyl website for the most up-to-date information, as details may have changed since publication.
When creating games for desktop platforms, it's important to understand that you can only publish games for the platform on which you are running Stencyl. For example, if you are running Stencyl on a Windows PC, you can only create desktop games for other Windows PCs, and if you are running Stencyl on Mac OS X, then you can only create desktop games for other Mac OS X computers.
Amazingly, if you want to publish to Apple's iOS devices using Stencyl, you don't need to own an Apple computer, which has been, until now, an expensive barrier to entry for would-be iOS game developers! The Stencyl Mobile and Studio annual subscriptions include access to the StencylBuilder service that enables Windows and Linux users to publish their Stencyl games to the Apple App Store as long as they are current members of the Apple iOS Developer Program.
There are many game development tools available, but Stencyl has some stand-out features that make it very different from its competitors.
Stencyl can be installed on nearly all popular desktop computers, and Stencyl files can be freely exported and imported between the different desktop platforms, which is very useful when working with friends or colleagues who use different platforms for game development.
Whichever platform we want to publish our game onto, Stencyl does all the hard work for us! It creates the game code specifically for that device, and it will not have to run the game in a wrapper that can slow our games down.
Although that might sound fairly technical, it just means that our games will run at the fastest possible speeds without us having to learn a new programming language for each target platform. Stencyl takes care of all the hard work when it comes to publishing to different target devices; we can just concentrate on creating our games!
Probably the greatest differentiator between Stencyl and other game development tools is the way in which the gameplay instructions are built. With many game development tools, you must hand-code the instructions in a specific programming language, which can be very tedious and time-consuming. Or, with some other development tools, you are required to point and click on the instructions that you want to select in order to build rules that the objects in your game will follow, which can be very restricting when it comes to complex gameplay.
The developers of Stencyl have created a system that offers an impressive set of options when compared to other currently available game development methods. There are four different options available to game developers when using Stencyl, so we can do the following:
Use Stencyl's built-in gameplay routines (called behaviors in Stencyl)
Download existing behaviors from StencylForge
Create our own behaviors using an intuitive drag-and-drop system
Hand-code our own gameplay instructions using a traditional programming language called Haxe
The magic of Stencyl is that we can mix and match any combination of the above development methods!
For example, if we want to create a basic game with common gameplay features, it's very easy to use Stencyl's built-in behaviors, and it's quite possible to develop a complete game in this manner.
At the time of publication, there were more than fifty built-in behaviors, a small sample of which is shown in the following screenshot:

Once we understand how the prebuilt behaviors work, we can either customize existing ones or we can create our own from scratch using the drag-and-drop behavior editor.
The following screenshot shows an example of a custom-built behavior, and even if you have never seen Stencyl before, you might be able to understand some of the instructions.

Finally, more advanced developers may choose to hand-code their own special game routines using the Haxe programming language (pronounced Hex, according to the main developer). This is certainly not a requirement for creating games, and many Stencyl users have never even tried this kind of development! Most Stencyl developers use a combination of prebuilt behaviors, customized behaviors, and also behaviors that they have created themselves, and these are the methods that we are going to be using throughout this book.
When our game is finished, we just need to decide which platforms we want to target, and Stencyl will do the rest with a few clicks of the mouse!

The free version of Stencyl has very few limitations compared to the subscription versions and in practice, you can use all the important game development features and make any kind of game with the free version that you can make with the subscription versions.
The main limitations of the free version of Stencyl are:
The great thing about the free version of Stencyl is that we can develop our games to completion, publish them for Flash or HTML5, and even sell them if we wish.
If, after publishing for Flash or HTML5, we find that a game is very popular, we can then pay for the appropriate Stencyl subscription and sell the game in the Apple App Store, or for Android devices in the Google Play store. We can learn how to use Stencyl and develop games for free to see if people like them, before paying for an annual subscription!
If you are a member of the Apple iOS Developer program, games can be created and tested for the Apple iOS devices with the free version of Stencyl, but they can't be published to the Apple App Store. In Chapter 10, Targeting Mobile Platforms, we'll look in more detail at the options available, and the requirements for publishing to mobile devices running iOS and Android.
In order to follow the game development tutorials in this book, only the free version of Stencyl is required. Subscriptions to Stencyl are only necessary for publishing to mobile devices and desktop applications.
The following matrix shows the major differences between the free and subscription versions of Stencyl:

Please note that the previous matrix provides only a summary of differences between the available versions of Stencyl. It is vital to check the Stencyl website (www.stencyl.com) for the latest features prior to making a purchasing decision, as the feature list may have been updated since publication.
Many successful games for Flash and mobile devices have been created with Stencyl. In some cases, they have been created by experienced developers who have switched to Stencyl to speed up the development process, and in other cases, the games have been developed by newcomers to game development, who had previously been unable to create their own games due to the complexity of traditional programming languages, or who had simply not attempted to create a game previously.
Following are three examples of successful games that were created using Stencyl:
Making Monkeys: Making Monkeys is an original, fun, platform game created by Greg Sergeant of greg-anims.com. The idea of the game is that very weird-looking monkeys can use a special weapon to duplicate themselves and solve various puzzles. Making Monkeys was sponsored by Armor Games and has gained over 1 million game plays.
Greg has stated that it only took him a few days to create the prototype of the game and that Stencyl enabled him to try out new gameplay elements very quickly.
Kreayshawn Goes to Japan: The first game that Beth Maher (www.bethmaher.com) created was called Kreayshawn: The game. The game, shown in the following screenshot, was created by her with Stencyl during a workshop project that was designed to encourage women to become involved in the indie game industry.
The development of this fan game led to Beth working with Columbia Records (part of the Sony group of companies) to produce Kreayshawn Goes to Japan, for Kreayshawn's fan website (arcade.kreayshawn.com). The game is a bright, imaginative platform game featuring Kreayshawn as the main character.
Impossible Pixel: Impossible Pixel and the Fate of Destiny, created by 99 Up Games, is a challenging platform game with 93 levels, available on iPad and iPhone. This game takes advantage of the touchscreen features provided by iOS; the buttons for controlling the player can be seen in the lower-left and lower-right corners of the following screenshot:
At the time of writing, Impossible Pixel, according to the developer's figures, had been downloaded from the Apple App Store approximately 700,000 times and had reached the position of the most popular free download on the App Store in nine countries. It was also the second most popular free download in thirty other countries, including the US App Store.
Impossible Pixel includes many professional features including Game Center achievements, high score leaderboards, atmospheric retro soundtrack, and many interesting challenges throughout the game.
The listed games are a very small sample of the successful games that have been published using Stencyl. The Stencyl website contains areas dedicated to showcasing games, and it's certainly worth visiting Stencyl Showcase for inspiration, and to see some examples of impressive games that have been created with Stencyl.
We've had a look at what Stencyl can do and how we are going to learn to use it. So, let's jump right into the next vital step and install Stencyl. The following section of the book is split into four parts. The first three parts will explain how to install and run Stencyl on each of Microsoft Windows, Mac OS X, and Linux, and the fourth part will step through creating an account and quickly testing Stencyl to make sure that everything is working.
Once we have Stencyl up and running, we'll head off into Chapter 2, Let's make a game!, where we'll quickly progress with the development of our first game.
Let's look at how to install Stencyl on each of the three desktop platforms that it supports: Microsoft Windows, Mac OS X, and Linux.
In this session, we're going to download and install Stencyl on Windows:
Visit www.stencyl.com.
Click on the Download Now button on the home page.
Depending on which web browser you are using and how you have configured it, the latest Stencyl installation file will start to download automatically, or you may have to confirm that you accept the download and specify the download location.
When the installation file has downloaded, find it in Windows Explorer and double-click it to start the installation process. You can see the dialog box shown in the following screenshot:
Click on Next to accept the default installation folder.
Click on Install to set the installation process running. Usually, the installation process will take less than a minute to complete, but the time may vary depending on the specification of your computer.
When the installation has completed, click on Next again to display the final dialog box shown in the following screenshot:
I recommend clicking on the Run Stencyl option to remove the checkmark so Stencyl does not run automatically.
Click on Finish to complete the installation of Stencyl.
Note
Because of the system access that Stencyl requires, you may need to run Stencyl as the Administrator on a Windows PC when updating or the first time after purchasing a subscription. This can easily be achieved by right-clicking on the Stencyl application icon and selecting Run as administrator.
We have just downloaded the latest version of Stencyl for Windows, and the installation is now complete. If you want to delete the installation file that you downloaded, then that's fine; it's not needed any more.
Note
When running Stencyl for the first time, we are asked to sign in. The signing in process is the same for all platforms and is detailed under the heading, Creating a Stencyl account, (after the Linux installation procedure in this chapter).
Stencyl will currently install on all versions of Mac OS X, but it should be noted that Java 6 must be installed in order for Stencyl to work.
Note
At the time of writing, Java 6 was a mandatory requirement for correct operation of Stencyl; Java 7 is not compatible.
The download and installation methods are the same for each version of Mac OS X, but the following screenshots have been captured in Mac OS X 10.7.4.
In this session, we're going to download and install Stencyl for Mac OS X.
Visit www.stencyl.com.
Depending on which web browser you are using and how you have configured it, the latest Stencyl installation file will start to download automatically, or you may have to confirm that you accept the download and specify the download location.
When the installation file has downloaded, double-click on the
stencyl.dmg
file to automatically mount it and start the installation process.When the application's files are ready to install, the following window will be displayed:
To complete the installation, click-and-hold on the Stencyl icon and drag it on top of the Applications icon. The Stencyl files will be copied into the
Applications
folder, and Stencyl is then ready to run!
We have just downloaded the latest version of Stencyl for Mac OS X, and the installation is now complete.
The stencyl.dmg
file can now be unmounted and deleted; it's not needed anymore.
In this session, we're going to download and install Stencyl on Linux.
Visit www.stencyl.com.
Click on the Download Now button on the home page.
Depending on which web browser you are using and how you have configured it, the latest Stencyl installation file will start to download automatically, or you may have to confirm that you accept the download and specify the download location.
When the download has completed, right-click on the downloaded
tar.gz
file and select the Open With Archive Manager option as shown in the following screenshot:Open the folder where the files were extracted.
Stencyl is now ready to run!
We have just downloaded the latest version of Stencyl for Linux, and the installation is now complete.
The Linux version of Stencyl doesn't really need installing – we just needed to extract the files to create the Stencyl
folder so that the application files are accessible.
If you want to delete the original download file, that's fine; it isn't needed anymore.
Although it is not a requirement to sign in to create games with Stencyl, we won't be able to publish any games, access StencylForge, or contribute to the Stencyl online forums without an account.
In order to follow the tutorials in this book, we'll need access to StencylForge, and we'll also need to be able to publish our games, so I highly recommend creating a Stencyl account and signing in.
Run Stencyl and the following screen will be displayed:
If you do not see the sign-in screen, ensure that you have Stencyl running, and select File | Sign In on the main menu at the upper-left corner of the Stencyl screen.
Click on Create an Account and enter your username, password, and e-mail address in the right-hand side of the dialog box shown as follows. Note that Stencyl usernames and passwords are restricted to alphanumeric characters (letters and numbers only).
When you are confident that you have entered the correct details, click on the Sign Up button, and after a few seconds a confirmation message will be displayed as shown in the following screenshot:
Click on OK to confirm, and we are ready to start using Stencyl!
We have created an account so that we can access the important features of Stencyl. The same account credentials can be used to log in to the Stencyl forums at community.stencyl.com.
You do not need to sign in and out of the Stencyl application each time you use it, because your login details are remembered unless you specifically choose to sign out using the File | Sign Out option in the Stencyl menu.
Why not visit the Stencyl community forums and say hello?
Fire up your web browser and visit community.stencyl.com, sign in to the forums using the account details that you have just created, and have a browse.
You could go to the Chit Chat forum, find the topic entitled Introduce Yourself!, and well, introduce yourself!
We're going to load up Stencyl, open one of the sample games that has been provided, and run the game to make sure that Stencyl is working properly.
Note
From this point onwards, all the tutorials will be the same whether Stencyl is running on Microsoft Windows, Mac OS X, or Linux, although the screenshots have mainly been taken using the Microsoft Windows version. On the rare occasion that there is a difference between the versions, it will be explained clearly in the tutorial.
If Stencyl is not already running on your computer, load it up and make sure that you have signed in with the account username and password that you created earlier, so you will see a screen that looks something like the following screenshot:
Don't worry if the list of games isn't identical on your screen, because the sample games packaged with Stencyl may be changed as software updates are released.
Double-click on the game icon for Alien Approach to open the game.
When the game has loaded, ensure that the target-platform drop-down option is set to Flash (Player), and click on the blue arrow labeled Test Game, both of which can be found at the upper-right corner of the screen, as shown in the following screenshot:
Wait for Stencyl to create the game and display it in the Adobe Flash Player window as shown in the following screenshot (this may take up to 30 seconds, perhaps more on a very old computer).
Play the game using the arrow keys to move left and right, and the spacebar to fire your weapons.
When you have finished playing the game, close the Adobe Flash Player window.
We just loaded a game into Stencyl and compiled it for the first time! Compilation is the process of converting the Stencyl game-code into a format that will run on our target platform. The default target platform is Flash, so when the compilation process has finished, the game will be displayed in an Adobe Flash Player window.
It's important to be aware that the sample games are not completed projects – they are just examples that have been provided so that we can see the kind of games that can be created. We can also use the samples to understand how the games have been put together, which is a great way to learn!
We've loaded and compiled one sample game and have had a play, so why not try some of the other sample games that have been provided?
Before we can open up another game, we should close the Adobe Flash Player window in which the previously tested game is running, and we must close the current game in Stencyl by clicking on File | Close Game and follow any prompts that appear.
Now, experiment with the other sample games, so that you become comfortable with the process of loading, testing, and closing games in Stencyl.
We've reached the end of this chapter!
We have examined what Stencyl is for and who will find it useful. We have also looked at why Stencyl is different from other game development tools, and we've discovered that Stencyl can run on virtually all desktop computers, and can create games for many different target platforms, including the latest Apple iOS and Android devices.
Finally, we stepped through the procedures for installing Stencyl on Microsoft Windows, Mac OS X, and Linux PCs, and then rounded off with a quick test, using a sample game to ensure that Stencyl was working properly.
We've learned a lot in this chapter, but now that our Stencyl installation is complete and has been tested, it's time to roll up our sleeves and start using Stencyl! In Chapter 2, Let's Make a Game! We'll very quickly build up the basics of our game, so that we will have a character that we can control as it explores the environment we are going to create for it.