Saturday, February 17, 2018

The Key to Animation

Animate uses a layer based keyframe animation system. For people who are not familiar with the creation of animation, this sounds complicated. It is a very quick and effective way of creating animation as the animator is just setting up guidelines for the computer to generate the majority of the  frames.

A keyframe is essentially a frame of the movie. Within the frame you place objects where you want them to be. Every time you want to change the contents of the frame you create a new keyframe. This by itself is not that powerful. Where the power comes from is with tweening. Tweening is a method where you let the computer animate the object for you. The word tweening is a concatenation of the term “inbetweening” which is where the lead animator would draw the key frames and junior animators would draw all the frames between the keyframes. Animate has two types of tweening. Motion Tweening and shape tweening.

Motion tweening moves an object from the location it is on the starting keyframe to the location it is when it is on the ending frame. You can also apply rotation to the object that is moving. While technically not motion, you can also adjust any color adjustments (such as the alpha level) and the adjustment will smoothly transition between the frames. As objects in nature don’t move at steady rates, you can use leading to have the object start the motion at a faster rate and slow down as it approaches the end keyframe or have it start slow and speed up as it reaches the keyframe. The image below illustrates the difference between the three types of tweening.

For even more advanced animation effects, you can have guides. Guides let you specify the path that a moving object will follow. You can have the object follow the path while maintaining the same orientation or you can have the object orient itself to the path. My April Fool series of games has a title sequence where each letter has a winding path to it’s ultimate location. The screenshot below illustrates the different paths that the letters follow to reach their final location.

Shape tweening is a bit complicated. Shape tweening is when you have one shape and it transforms itself into the second shape. This is easy to do, but hard to do well. You simply need two shapes, a starting shape on the start keyframe, and an ending shape on its ending keyframe. To make sure the shape morphs the way you want, you add key points to the shapes. These points help Animate determine where the lines and points that make up the shape should line up after the end of the tween. Here is an example of a square turning into a star with the red shapes being the onion skin outlines of the frames between the square and the star.

An Animate movie consists of one or more layers. Layers go from back to front with closer layers overlapping further layers. Every layer is independent of the other layers. In other words, you can have keyframes in one layer but not any of the other layers. Animate lets you define as many layers as you need and lets you group the layers into folders. It is advisable to keep each animated object on its own layer as not doing so will result in animate creating a separate tween object in the library which often leads to problems.

The animation system is the primary reason why you would choose to create a game in Animate instead of creating it from scratch using the free Create.js libraries. While everything listed above can be done manually in Create.js, having a tool that generates all the source code for you is nice. If your game is a very heavy animation-oriented project, then using Animate makes sense.

Using animate to create the animations for a game project but then doing that project manually using Create.js or some other library (or even another language) can also be a consideration. In a team environment, this approach can be very cost effective as you would only need creative cloud for your art team while the development team can have other development tools.

Saturday, February 10, 2018

Symbolizing things

Animate revolves around symbols. Symbols are a very efficient way of building movies, as a symbol only needs to be loaded once. After it has been loaded, you can create as many copies - known as instances - as you want to. More importantly, every instance of a symbol can have properties independently applied to it. You can adjust the size, orientation, and skew. You can also apply tinting, control the brightness, adjust the alpha (transparency) level. There are three basic types of symbols that Animate uses. The Graphic symbol, the Movie symbol and the Button symbol.

Graphic symbols are just a drawing converted into a symbol. The drawing can be as simple or complex as you desire, and can even contain other symbols as part of it. These tend to be vector based, but it is possible to use bitmaps for graphics. Flash used a very compact binary format for vector images making them take significantly less space than bitmaps in many cases. Animates’ HTML5 exporting converts these vectors into Create.js shapes which take up significantly more space, especially if you are not letting Animate compress the images.

A movie symbol is essentially a movie within the main movie. You have as much control over an Animate movie symbol as you do over the resulting movie. You are not limited to having a single level of movie clip as movie symbols can contain other movies as part of them, which can contain movie symbols within them which can contain movie symbols within them and so on. While this recursive nature of movie clips adds a lot of flexibility to creating animations, movie clip objects are fairly heavy in memory and processing requirements so having too many nested movie clips can slow things down substantially.

A Button is simply a special symbol that has special actions associated with it whenever the mouse is over it or the mouse has been clicked while over it. To be more precise, a button has 4 frames associated with it. The up frame is simply the normal appearance of the button. The over frame is how the button looks when the mouse is over it. The down frame is what the button looks like when the mouse is over it and the mouse button has been pressed. Finally, the hit frame defines the over/hit areas.

The hit frame may seem confusing to people new to Animate. This frame is not actually seen by the viewer, but is instead used by Animate. How it works is any area in the hit frame that is solid will react to the mouse being over it while an area that is not solid will be ignored. While touch users will not get the mouse over effect, the hit area is used for determining if a touch results in a down event.
Some of you may be wondering why you would want or need such a thing? Couldn't you just use the existing button image? The answer to that is you could, but then the button would only work if the user had his or her mouse positioned in a solid part of the image. In some cases, such as with our Play the Game button, we want the button to react if the mouse is within a block or an area that covers more than the frames cover. Conversely, you may not want a rectangular region or even the entire button to be clickable. The hit mask gives you total control over where the button can be clicked.

As an example, here is a button that I use for switching a sound from enabled to disabled. The top right image is the normal image and is what the user will see normally. The top-middle image is what will be shown to mouse users who move the mouse pointer over the image. The top-right image is what is shown when the button is clicked or touched. Finally, the bottom image is the hit map that is used for determining if the mouse is over the image.

Symbols can be created in animate simply by drawing something and then selecting the drawing and choosing the “convert to symbol” option from the right-click menu or the modify menu from the menu bar. Creating a symbol adds it to the library. Empty symbols can also be created from within the library, though personally this is not something I do. The library is a file-folder structure allowing you to easily arrange your symbols to make finding and working with them much more efficient. This is especially true when you get to larger projects that contain hundreds or thousands of objects.

Libraries also have the benefit of being sharable between projects. Animate makes it easy to move symbols between different libraries allowing you to create a standard set of library symbols that can be copied between libraries. There are also built in tools for converting a selection of library symbols into image atlases or stand alone files which can come in handy for environments where animators create assets in animate then hand them off to developers who are using pure JavaScript (or other language for non-HTML projects) for creating the application.

Saturday, February 3, 2018

Drawing Things Out

Animate, as mentioned earlier, is a vector based drawing and animation tool. All drawing in Animate is built around shapes. Shapes are made up of a series of connected lines and curves. You create the shapes by using basic building blocks such as lines, rectangles and ovals. You also have text, which can be treated as text or converted into a shape so that you can modify the shape. By breaking apart text twice you are given the vector shape of each character and can then use the arrow manipulation tools to alter the letters which can be great for creating title text quickly.

Shapes can have an outline and a fill, or can be just one of the two. The outline has a color, a thickness, and a pattern associated with it. One of the most unique thicknesses is the hairline. This is a special thickness as it will always be drawn as thinly as possible.

The fill of a shape can be a solid color, a gradient, or a bitmap fill. Gradients are a series of colors that gradually change from one color to the next color in the series. You may have as many colors in a series as you desire and can vary where in the gradient range the colors will change. Gradients can be linear or radial and the orientation, scale, and center spot can be adjusted. A bitmap fill is a bitmap image that is used to fill the shape. Bitmap fills are tiled, though you can adjust the orientation, scale, skew, and center spot.

For more complex shapes you can use a pencil tool. The pencil tool takes whatever shape you draw and turns it into a series of lines and curves. You can control how close to what you draw the pencil will be, with the more accurate the representation, the more anchor points in the object. The pencil tool is supposed to be intelligent, so it will try to figure out the shape you are drawing picking the most appropriate approximation it can come up with. The pen tool is just like the pencil tool except instead of lines it deals with fills.

The fountain pen tool lets you build a spline shape. The mathematics and techniques behind splines are interesting but way beyond this book so I will try to explain in simplified terms. A shape is made up of several points that define the basic shape. These points are connected via lines which can each be edited separately. For shapes made of straight lines this is fine, but for curved shapes, splines are used. Each line has additional points (weights) that control how much the line curves between two points. Curves can be controlled by adjusting the weight points for that line segment. You can adjust these points by using the sub-selection tool which looks like a white pointer.  While editing a shape this way can be painful, it gives you extreme control of the resulting shape.

The basic drawing tools within Animate are enough to do quite a bit and may be all that an artist needs. If better tools are needed, a vector package like Illustrator can be used. It is even possible to import a bitmap image and use a tracing tool that will convert the image into a vector shape.

Saturday, January 27, 2018

The Road to Animate

Younger readers may not fully appreciate how much the internet has changed over the years. When I started using the internet in the nineties it was done with a device called a modem which plugged into your phone line meaning that when you were connecting to the internet you were making a phone call to your internet service provider. The modem I originally had was a 28000 baud modem which means it was able to send and receive 28000 bits or 0.028 megabits which is roughly 3k per second under optimal conditions. This is really slow so video was not really something that you would have on a website. Even images were really slow where with large images you could actually see the image being loaded. This is why vector based animation systems actually made sense and why Future Splash was pretty impressive for its time. Instead of sending the bits that make up the image, vector systems would just send the points and edges that make up the shapes. For simple shapes, like those in early internet animations, this was significantly less information than the bitmap representation of the image so could be transmitted much faster.

Future Splash was competing with a technology that Macromedia was pushing called Shockwave which was acquired by Macromedia when they purchased MacroMind for their Director game making software. Macromedia acquired Future Wave, the company that was behind Future Splash, so they could add the vector animation tool to their shockwave platform. This is the reason why Flash binary files have the swf extension which stands for ShockWave Flash.

When Java arrived on the scene Java applets (note that Java and JavaScript are not the same thing) were still thought to be the future of interactive web pages. Browsers were being shipped already loaded with Java while Flash required a plug-in program be downloaded and installed into your browser. The Java craze was so strong that even Macromedia had an optional Java version of their Flash player. I was hired to see if it would be possible to have a Flash game where the animation was handled by the Java-based Flash player and game logic would be written in Java. This proved to be clumsier than expected and pure Java solutions were chosen for the project.

While I think Java could have taken control of the browser, this ultimately failed due to a conflict between Microsoft and then Java-owner Sun Microsystems. Sun wanted Java to be a standard that would work the same on all browsers while Microsoft wanted to be able to make Windows the operating system of the internet and added extensions to the internet explorer version of Java that made it work better on Windows due to the ability to access Microsoft APIs such as Direct X. A court battle ensued, Java on the browser stagnated, and alternatives for Java started being looked for.

This is roughly the time that ActionScript was added to Flash. While not the greatest scripting language, this made the product useful for games and other interactive web content and ultimately replaced Java as the go-to technology for interactive web sites.  I started using Flash and wrote the original Flash Game Development book that this book is based on and everything was good with the exception of the occasional exploit, too many sites having intro movies created in Flash, and many extremely annoying interactive ads which happened to be written in Flash though would have also existed in any other alternative had there been an alternative with a large enough market share.

Flash was still a very strong standard when Adobe bought out Macromedia. Unfortunately for Adobe, things were about to change thanks to a fruity company releasing a phone a couple of years later. While saying that iPhone not supporting Flash was the cause of its demise is not the full story, it was certainly a big factor. The idea of plug-in for browsers was starting to be looked on as a negative factor as plug-ins were increasingly the target that hackers used to attack browsers.

The ultimate nail, in my opinion, was the release of HTML5 and the Canvas API (which if I recall correctly was an API designed by Apple for their browser). This allowed for web developers to do everything that Flash could do right within the browser knowing that all users with a browser could run the program. Granted, the HTML5 apps were slower and larger than the equivalent Flash files, but they worked without any plug-ins.

Flash was not just used for creating web pages, but was still a popular tool for animation studios. With the death of Flash on the browser rapidly approaching Adobe decided to handle the death of Flash by renaming the tool Animate which reflects the target audience for the tool. To help support browser developers, Adobe did introduce the HTML5 stage which allows the creation of HTML5 projects that convert Flash vector objects and animations in to JavaScript using the Create.js library. The ActionScript code is not currently converted to JavaScript so any interactive code must be written in JavaScript using Create.js library calls.

So while Flash is dead, Animate is not and can be used as a tool for the creation of HTML5 animated content. For people who have used the Flash development tools, things have not changed that much and you will quickly find your way around the tool. For those not familiar with the tool, there are several built-in tutorials and a decent manual that can be downloaded.

Saturday, January 20, 2018

Flash is Dead! Long Live Animate!

The first exposure I had to Flash was when I encountered some FutureSplash animations in the mid-nineties. This was interesting technology at the time as back then most people were using telephone lines and modems to get internet pages so having streaming animated video was simply mind boggling. Back in those days, streaming video was small thumbnails and generally didn’t work well.  In “The Road to Animate” we will look at this history as well as my personal history with the technology.

One of the biggest draws of using Flash, now Animate, was animation. Before you can animate something, however, you first need to draw it. “Drawing Things Out” covers the basics of the drawing functionality that comes with Animate. “Symbolizing things” explores Animates’ symbol and library which is vital to making objects move. “The Key to Animation” explores Animates’ keyframe animation system which really is the reason that you would want to use Animate over writing an HTML5 game purely in JavaScript, even when using a library such as Create.js.

We conclude this chapter with “Script Soup” which takes a look at how scripting is involved in the game making process. This is a rough exposure to ECMAScript, ActionScrpt, and JavaScript with a general overview of the Create.js library.

Personal notes

After finishing my Bachelor degree and looking back at my site I realized that there was a lot on my site worth saving. I was not sure what route to take but essentially knew that I had to at least attempt to salvage some of the games. Finding my old book on Flash and deciding to undertake this book project, which is now a two-book project and I suspect additional volumes may be added in the future (possibly for StageGL, Kotlin, and Web Assembly). The reason I decided to break the book into two separate books was simply that after playing around with Adobe Animate CC, I was disappointed with what the tool has to offer and found that most of my work was being done editing Create.js code. You do not need an expensive tool to do that which is why I broke this book in half. With that said, most of the material in this book is still applicable to people who want to go the pure Create.js route so if you have no plans on getting Adobe Animate CC, you can still benefit from reading this (especially now that it is being freely posted on my Blog).

Saturday, January 13, 2018

HTML5 Games using Animate CC Overview

A long time ago, back in 2003-2006, I wrote a virtual book for Blazing Games which covered the creation of ten Flash games. When we closed down Blazing Games in September of 2014 the IP rights to the games on the site went to me, including the Flash Game Development book. With browsers moving away from Java (right now the Java games won’t work) and Flash (in 2020 support for Flash will cease), all these older games need to be moved to HTML5 which uses JavaScript. Browsers are also starting to support Web Assembly, which may be a book on it’s own depending on how well received this book and the follow up HTML Games using Create.js are received. When I say HTML5 I am talking about the combination of HTML, CSS and JavaScript which happens to be the common usage.

As Flash is dying or dead (depending on when you read this), games created for it need to be ported to another language so I decided that it would be a good idea to revisit the 10 games that made up the book and port them to HTML5. Five of them (NIM, Nightmare Maze, Video Poker, Pent Up Anger, and String Along) were ported taking advantage of Animate CC to port them to HTML5. The other five games in the book will be covered in a second book HTML5 Games using Create.js which can be developed without purchasing any additional tools for your computer. This book will cover Bomb-NIM, Cribbage Square, 3D Tic-Tac-Toe, Lights Out, and “Dragon and the Sword”.

Chapter 1: Introduction – An overview of the book, and what you are reading right now. I am skipping a bunch of less-revevant sections of this chapter.

Chapter 2:Flash is Dead! Long Live Animate – Quick look at the history of Flash, how the new Animate CC is a replacement for Flash, and what Create.js has to do with all of this when creating JavaScript games using Animate CC.

Chapter 3: Procedural JavaScript – A very quick course on the procedural programming aspects of JavaScript with a brief look at how it compares to ActionScript.

Chapter 4: NIM – We finally get to our first game, which is a variant of NIM. This game tries to do as much as possible with Animate and as little as possible with JavaScript.

Chapter 5: Objects in JavaScript – we get into the object oriented nature of JavaScript which will be used for creating our own objects and a library that can be shared between similar games.

Chapter 6: Nightmare Maze – The game that became the first episode of my 46 part One of those Weeks game is created as we look at adventure games.

Chapter 7: Card Classes – Creating code to be shared between multiple games is a common activity so this will be demonstrated by creating a card class.

Chapter 8: Video Poker – The Card class that was created in the previous chapter is used to create a virtual Video Poker machine.

Chapter 9: Pent Up Anger – Making base game of Pent Up Anger

Chapter 10: Pent Up AI – How to create artificial players for a game is demonstrated by adding computer opponents to the Pent Up Anger game.

Chapter 11 String Along – Arcade games are demonstrated using a variant of the classic snake game.

Chapter 12: Conclusion – A summary of what was covered and a look at the second book in this series.

Saturday, January 6, 2018

Calendar NIM Review

Normally I like to have a postmortem or a making of article about the games that I have just released, but the nature of my Calendar NIM game makes an explanation of the twelve months a bit more appropriate. Each image represents a game that I am hoping to release during the year, though it is subject to change. The games chosen are not the only games that I will be releasing, but are simply the ones I am positive that I can finish though are subject to change and unexpected delays. Still these games are pretty certain. For those of you who haven't looked at my Calendar NIM game, it is located at

January is a 2018 New Years image that was released by LMoonlight for free and is used to represent the Calendar NIM game itself.

February is Video Poker, which was a game that I created for my original Flash Game Development book which is in the process of being re-written for HTML5 development which will start being posted on this blog next week. This game has already been completed so this is a guaranteed release.

March is when I release my Easter game which is the egg generator. While this was really low on the vote, the generator is used in two other easter games so I am going to port the generator first. This will be challenging as the masking technique I used is  not supported in Create.js so I will need to come up with a different approach. As this game is not going to be released until the end of the month, I will probably take the opportunity to release my NIM game as a bonus.

April 1st is Easter so my April Fool games will have to wait until next year. The thirteenth of April is on a Friday so the original version of thirteen squared spikes will be the choice for that month. This game has already been completed so it is a guaranteed release.

May 25th is towel day so it makes sense to release Towels for Earth. I am not sure why this game is so high on the voting chart but this is the most appropriate day to re-release the game. I have not done any work on it at all but it is not a difficult game (it was created in a game jam after all) so this shouldn’t be a problem. As this is late in the month, I may also release Pent Up Anger which I have already finished.

June is really subject to change but I am planning on porting Fleet to C++ and using emscripten to convert it to asm.js or to web assembly. I started playing around with emscripten for my 2600 emulator project but pretty much have gone the Kotlin route with that project so this would be a good project.

July is another month with a Friday the Thirteenth in it so the Thirteen Spikes Unlimited (TSU) port would possibly be ideal. The current version of TSU was written in HAXE and compiled to Flash as there were issues with the JavaScript compilation. I will see if things have changed with that and if so this is simply re-compiling the project. If not, I have the core of Thirteen Squared Spikes to use as the base of this so it should be a very quick port.

August has String Along set up as it’s game which has already been completed so is guaranteed.

September is Coffee Quest which will be a WebGL game. As with Fleet, I will likely port this game to C++ and use emscripten to convert to web assembly and Asm.js. The construction set will not be part of this, but the extra maps may be. At the moment I am thinking of going weekly for september releasing a new map each week. This is just speculation at the moment with a final decision on what I will do to be made in September.

October is Nightmare Maze which happens to be the first episode of One of those Weeks. It is being referred to as Nightmare Maze as it is part of my book. I have big plans for One of those Weeks so there will be additional news about the project later this year (I hope).

Let’s face it. Coffee Quest was a very simple game, with the series only really starting to take of with the release of the second game in the series. This is why November will be Coffee Quest 2. It will be built on top of the Coffee Quest code base so will be in whatever language Coffee Quest ends up being released in. Again, I may release the extra maps every week but that is not certain yet.

Finally, also likely using the Coffee Quest engine, will be the high-def version of Santa’s Snowball. Higher resolution, better graphics, better sound, and 360 degree movement with an automap will make this Christmas game what I wish it was in 2017.

There may be additional surprises throughout the year, hopefully one involving One of those Weeks, but even without the extra releases I don’t think the year is too bad.