Stencyl Essentials

4.5 (2 reviews total)
By Richard Sneyd
  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies
  1. Exploring the Stencyl Toolset and Game Engine

About this book

With the incredible growth in the global games industry over the past few years, Stencyl makes it possible for anyone to learn how to create amazing, engaging, and polished 2D games in just a fraction of the time.

Whether you are new to game development or an experienced developer looking for a quicker, more intuitive way to prototype, develop, and publish your game ideas, this book will show you how to achieve your game development goals using Stencyl. By following a clear, step-by-step development cycle for our first game prototype, you will rapidly gain a working knowledge of the Stencyl game engine and toolkit. With ample screenshots, you can be certain that you’ll be able to follow along at every stage.

Publication date:
April 2015
Publisher
Packt
Pages
206
ISBN
9781784399450

 

Chapter 1. Exploring the Stencyl Toolset and Game Engine

Stencyl Essentials has been written as a no-nonsense, concise guide to acquiring the functional use of Stencyl in as little time as possible. To achieve this, little or no time is wasted discussing the basic computer science and/or programming concepts, as this fundamental knowledge is assumed on the part of the reader. In line with that, highly detailed instructions on how to download and install Stencyl will not be provided, as this is not considered to be a challenging process for someone with previous computer science experience. However, a simple, lucid outline of the process will be provided.

In this chapter, we will begin by downloading and installing the free version of Stencyl. The free version is all that is required to complete the lessons in this book. Immediately after that, we will begin exploring and rapidly become acquainted with the Stencyl interface, including all of the most important areas and layouts, which are as follows:

  • Sign-in window

  • The Welcome Center

  • The Dashboard

  • StencylForge

  • Stencylpedia

By the end of this chapter, we will be comfortable enough to use Stencyl in order to be able to navigate through the most common screens, windows, and tabs at will and with relative ease. This newfound facility and comfort will stand us in good stead in the subsequent chapters, which will be fast-paced and punchy in the manner in which the new information is presented. Redundancy will be avoided wherever possible, which means there will not be a lot of needless posturing or repetition. So without further ado, let's start learning how to build games with Stencyl!

 

Downloading and installing Stencyl


Stencyl can very easily be downloaded free of charge from the official Stencyl website, www.stencyl.com. When you visit the landing page, you will see something that resembles the following screenshot:

Click on the Download button, which is prominently displayed on the landing page. You will then be given the option to download either a Windows, Mac, or Linux build:

Simply select the appropriate build for your operating system, and click on Download. This could take anywhere from 20 seconds to 20 minutes depending on the speed of your Internet connection and the size of the particular Stencyl build you are downloading. Once the file is downloaded, launch the installer (if you are installing for Windows), follow all of the prompts, and when the installation is completed, you will have the option to launch Stencyl. If you have downloaded the Mac version, you will have to extract the stencyl-full folder from the downloaded ZIP file, then put it in the Applications directory for it to become useable. Once you have completed the appropriate steps, launch Stencyl.

Tip

For Linux users, the installation process may be a little more complicated. It is beyond the scope of this book to delve into such particulars. However, there is an excellent guide to the Ubuntu installation on the Stencyl website itself, which is available at http://www.stencyl.com/help/view/install-stencyl-linux.

 

Creating an account and signing in


When we first launch Stencyl, it will ask us to either sign in with an existing account or register a new account. If you have already registered for the Stencyl forums, then you do not need to create an account here. The same login credentials are used to access Stencyl as well as the forums. You will see something similar to this in the following screenshot:

You need to complete one of these two tasks, obviously depending on whether you have a pre-existing account or not. Once this is done, we will be ready to explore the most important Stencyl screens and windows.

 

Exploring Stencyl – screens and windows


In this section, we will explore the most common fundamentals of the Stencyl screens and windows, briefly examining their basic nature and purpose, and learn how to navigate to them effectively and easily.

The Welcome Center

The Welcome Center is the first screen you will see after you first open Stencyl. Let's take a look at the following screenshot (your list of games will be different from mine; do not worry about this fact):

You may notice right off the bat that Stencyl does not have a native interface, whichever operating system you may be using (Windows, Mac, or Linux). In terms of style and aesthetics, it is entirely its own beast. The good news is that, because the toolset is written in Java, Stencyl looks much the same whether you're using it on Windows, Mac, or Linux. This is advantageous, as it is quite easy for us to jump from one OS to another without being disorientated by stylistic differences. What is more, games can be exported and imported between the installations of Stencyl as .stencyl files, across all the three supported operating systems, so you're never tied to just one OS. Let's look more closely at the important areas of this layout.

Drop-down menus

At the top-left corner of your Welcome Center layout, you will find a very familiar looking list of menus (see the following screenshot):

Here, we will find the very typical File menu that contains the menu items for common tasks, such as opening and closing games, importing resources (assets), importing and exporting games, signing in or out, and closing Stencyl. You will notice that some of the options in these menus are grayed out. This indicates that they cannot be clicked on in the current view. This is logical, as certain tasks can only be performed in appropriate contexts; for instance, it should be obvious that we can only click on Close Game when we already have one opened.

Next, we have our View menu, where we can switch between tabs, show or hide the Toolbar (the area that is shown at the bottom of the preceding screenshot), open up StencylForge, Stencylpedia, Game Settings, and the Log Viewer, all of which are important and will be discussed in good time. You will notice, as you scan the contents of the View menu, that the options have associated keyboard hotkeys. You may find it expedient to learn these, as it can improve your workflow with Stencyl in the long run.

The Run menu is only useful to us when we are inside a game project. It contains options for testing our game on various platforms, debugging tools, and so on. The Publish, Extensions, and Debug menus are likewise only really relevant when we have a game open. We cannot use them in the Welcome Center.

The toolbar

The toolbar, which is shown at the bottom of the previous screenshot, shows buttons for the following common tasks and windows:

  • Create a new game

  • Save a game

  • Import

  • Open the game settings window

  • Show log viewer (primarily for debugging)

  • Sign in

  • Access StencylForge

  • Open Stencylpedia

The Welcome Center tab

To the left of the layout, and as demonstrated by the following screenshot, we can see the Welcome Center tab (at the top-left corner of the window). All the screens in Stencyl are tabbed, so you can have several open at once. This includes scenes and actors, which we will learn about a little later on.

In the following screenshot, you will see that we have three drop-down menus:

  • My Projects: Click on this tab to see your existing game projects, or any game kits (a starter pack for a certain type of a game) you have at your disposal.

  • Download: When you click on Sample Games, it will take you to http://www.stencyl.com/developers/samples/. When you click on Extensions, it will take you to http://www.stencyl.com/developers/market/. Here, you can download extensions created by advanced Stencyl users, which add functionality to Stencyl.

  • News: This is a collection of links that will take you to the social media pages related to Stencyl, the Stencyl Blog, or the Forums. The Forums are an excellent resource for one and all, as they enable all members of the community to share resources, ask and answer questions, collaborate on projects, and engage in idle, Stencyl, or game-related chit chat—all of which are good things. There is also a members-only area, where paying subscribers receive extra support and assistance from the Stencyl team.

Now, it is the right time to download a demo game so that we can use it to explore the Dashboard and other important areas of the Stencyl interface, which are only accessible from within a game:

  1. Let's click on the Sample Games link.

  2. When the Sample Games page opens in your browser, click on the download button for Alien Approach.

  3. When the download completes, you should have a file called AlienApproach.stencyl. This file can be imported into Stencyl by navigating to File | Import Game. Then, you can navigate to the directory where you downloaded the sample game to (likely, your downloads folder).

  4. Double-click on the file to import it. After a few moments, you should see a new game appear in your games list that looks similar to the following screenshot:

  5. Double-click on the game to open it. We will use this sample game to explore our next major screen, the Dashboard.

Tip

A great way to get familiar with Stencyl quickly is to download all of the sample games we have seen earlier and tear them apart to see how they work.

The Dashboard

Once we have opened up our game, the Welcome Center disappears, and it is replaced with the Dashboard. This is the main view within our game. From here, we can access all of our game resources, such as Scenes, Actor Types, Tilesets, Fonts, Behaviors, and Sounds. In the following screenshot, you can see that these resource types are listed in the drop-down menu immediately below the Dashboard at the top-left corner of the page, under Resources:

Let's very quickly click on each one of these resource types, starting with Actor Types and working down. You will see that as you do so, the contents of the main window changes; we are presented with a list of all assets of that particular type. When you've gotten as far as Tilesets, let's move on to the Logic drop-down menu immediately below it.

You will see that in this menu, we have three submenu items: Actor Behaviors, Scene Behaviors, and Code. Actor Behaviors are attached to Actor Types or individual instances of Actors, and modify their functionalities with conditional logic. They are akin to components, which you may have worked with in other game engines, such as Unity.

Scene Behaviors are similar, except that we attach them to Scenes instead of Actors. Clicking on Code will allow us to write our own classes. This is an advanced feature, which we rarely need to utilize, but it's good to be aware that the feature is available to us, as our abilities in Stencyl develop to a more advanced level.

Believe it or not, these nine menu items constitute all of the major asset types within our games. Once we have learned them all, and how they relate to and interact with each other, we will have a working knowledge of Stencyl and will be quite capable of building our own games!

Scene Designer

Let's go back to the scenes view by clicking on Scenes in our Resources menu. You will see that there is already one demo scene in this example game. Now, double-click on it to launch the scene designer and edit our scene. You will be presented with an additional tab with the name of your scene on it, beside the Dashboard tab, and a screen as shown in the following screenshot:

Let's take a closer look at the six tabs that we see at the top center of the screen:

Clicking on any one of these will change our view to show tools and fields that relate directly to a certain aspect of our game. Here is a cursory breakdown of the different tabs and their relative significance in the crafting of a playable game level:

  1. Scene: This is where we sculpt the level by placing tiles and actors on various layers. To the left of the screen, you will see a tool palette, which is similar in some respects to what you might find in a graphics manipulation tool, such as Photoshop or GIMP.

  2. Behaviors: Here, we can add or remove Scene Behaviors as well as assign values to the exposed attributes; we'll be learning more about the attributes shortly. For now, just think of the term attribute as a synonym of the term variable, which is commonly used in math and programming vocabulary.

  3. Events: While we usually use events within our behaviors, there are some instances where we may decide to create a single event that is associated directly with the scene object. In any case, we will not be using this tab as often as the Behaviors tab.

  4. Physics: This is where we can set both horizontal and vertical gravity for our game level. How this gravity affects the individual actors within the scene will depend on how we have configured that specific actor's physics settings.

  5. Background: This is where we can add backgrounds and foregrounds to our level, which can be repeated horizontally and vertically. If desired, we can also add parallax scrolling settings—an effect that is popular in platformer games.

  6. Properties: This tab opens a window where we can alter certain basic scene properties, such as the Name, Size, and Background color (or gradient, if you should choose to use one).

Tip

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

The Palette

The Palette, which can be located to the right of the scene view (which is active by default when you first open the scene), is where we can go to select the tiles and/or actors we wish to paint onto the canvas. As you can see from the following screenshot, there are two tabs available to us within the palette—one shows the available actors, the other shows the available tiles that can be placed in our scene:

As we can see from the palette display, this particular game demo happens to contain only two tiles and seven actors in total. Some games can contain hundreds of each. If you take a look at the area above the palette area, you will see something similar to the following screenshot:

In the preceding screenshot, we have, from left to right and starting at the top, the following options:

  • Platform: Flash is the default choice. Click on the button to see a drop-down menu displaying all your available options. Which options are displayed here will depend on what operating system you're using. If you're using Windows, for instance, the options will be Flash (Player), Flash (Browser), Windows, and Android.

  • Test Game: By clicking on this tab, you can build and then attempt to launch the entire game for the specified target platform. The default scene, as identified by the star symbol, will be the first one to launch. Bring up the Log Viewer in tandem to view progress, warning, and error messages.

  • Test Scene: Unlike the Test Game button, this only builds the current scene, and launches it directly, ignoring the rest of the game. The Log Viewer can be used for debugging purposes, as before.

The Log Viewer

Let's learn more about the Log Viewer. The easiest way to launch this tab is by clicking on the quick launch button, which has conveniently been placed on the toolbar for us; a permanent fixture at the top of the Stencyl interface. Let's click on that button now, and then click on the Test Scene button we learned about just moments ago. After a moment or so, you should see the following window appear (on Windows – the Mac version is a little different), and start to fill with lines of information:

As you may have deduced, the information we are fed through the Log Viewer comes in the form of Events. These events, in turn, come in five basic categories:

  1. Debug: These events are useful for debugging. We can trigger this type of event ourselves to assist in the debugging code.

  2. Info: These events are helpful updates to let us know what is happening during the build or execution process of our program. They do not indicate a problem.

  3. Warning: These events indicate a possible problem in the execution of our code.

  4. Error: These events indicate that something has gone wrong. The Source and Message events will usually provide clues as to what has happened.

  5. Fatal: These events indicate that a fatal error has occurred, and the game can no longer execute.

Your cursor over each of the buttons is indicated in the following screenshot (to be found at the top-right corner of the Log Viewer window):

The first five color-coded circles enable us to toggle the different types of events to on or off. They occur in the same order that we examined earlier, beginning with Debug and ending with Fatal. When your game code is executing, the sheer volume of information being presented through the Log Viewer can be overwhelming, and hence, difficult to process mentally. Use these buttons to filter the displayed events, thus making it easier to read/debug.

The next three buttons relate to highlighting significant events for later consideration. The first one is the Marker. Simply select an event from the list, and click on this button to mark it. When you have marked multiple events, you can use the next two buttons to move up and down the individual items in your selection of events. The last button, in the form of a red X, will clear all of the current events.

Tip

You can experiment with the features of the Log Viewer discussed earlier, including the filtering options and marking tools. Take some time to absorb the basic purpose of each event type (or event level). Becoming comfortable with all these fundamentals now will speed up our progress throughout the chapters that follow.

 

Summary


In this chapter, we familiarized ourselves with the non-standard, yet beautiful and intuitive interface of Stencyl. Together, we examined many of the most important areas and views in the Stencyl toolset, including the Welcome Center, Dashboard, Scene Designer, and Log Viewer. Having acquired a basic understanding of the structure and layout of Stencyl, we are now ready to begin our fast-paced development project, the completion of which will lead to our mastery of the software. Let's begin – see you in Chapter 2, Starting the Game Project!

About the Author

  • Richard Sneyd

    Richard Sneyd (BA Hons.) is the founder and CEO of CyberMyth Games, an indie game development studio based in Country Cork, Ireland. His role within the company requires that he wears many hats, including that of a programmer, designer, digital 2D and 3D artist, sound designer, scriptwriter, texture artist, leader, marketer, and business man.

    He is also a fully registered, qualified, and highly experienced lecturer. His specialty subjects include 3D modeling and animation, computer game programming, 2D image processing, game design, desktop audio, psychology, consumer behavior, human resources, and business management. In addition to classroom teaching, he is actively involved in online education, regularly publishing new courses, and various other learning materials, such as books and tutorials, in conjunction with CyberMyth Games.

    He is enthusiastic about his work, and his students and colleagues think of him as a very dedicated and accomplished teacher. All of his courses and books are characterized by a steady, incremental flow of information, and a lucid teaching style that is easy to understand and follow for all.

    He is a husband to his wonderful wife, Jennifer, and father to a wonderful son, Darius.

    Browse publications by this author

Latest Reviews

(2 reviews total)
It's a good introductory book.
Well explained for a 7 year old only with a little assisitance from a parent.
Book Title
Access this book, plus 7,500 other titles for FREE
Access now