Endless runners: These games automatically move the character, and the player is responsible for jumping over obstacles or otherwise interacting with the game. The player typically only has one or two options when it comes to controls. Brawlers: These are typically side scrolling and task the player with defeating enemies to progress. The player character often has several moves that they can perform to defeat enemies. Puzzles: These games ask the player to solve puzzles to beat each level. These can range from Match-3 style such as Bejeweled to more complex puzzle solving typically found in Adventure games. RPGs: These games focus on character development and progression, and have the player moving through multiple environments with a variety of enemy types. Combat mechanics vary wildly from RPG to RPG, but many are turn-based. RPGs can be significantly more difficult to code than a simple action game.
Flash games are also best suited for quick sessions. This is because most Flash game players play when they have a little free time, such as on breaks, meaning gaming sessions are typically 15 minutes or less.
Flash Professional is the only program you will need to start creating games.
Variables - This is how your data is stored. Data can be numbers, words (strings), objects, and more. Variables are defined by the code var and must be one word. var playerHealth:Number = 100; // “var” designates that you are defining a variable. // “playerHealth” is the variable name. // “Number” is the type of data. // “100” is the value assigned to the variable. // All actionscript lines end with “;” Event Handlers - Event handlers look for specific things to occur, and then tells the rest of the program. This is essential for player input and repeating code. Event handlers typically call upon functions. addEventListener(MouseEvent. CLICK, swingSword); // “addEventListener()” defines the event handler. // “MouseEvent” is the category of input that is being listened for. // “. CLICK” is the specific event in the MouseEvent category. // “swingSword” is the function that is called when the event occurs. Function - Sections of code assigned to a keyword that can be called upon later. Functions handle the bulk of your game’s programming, and complex games can have hundreds of functions while simpler games may only have a few. They can be in any order since they only work when they are called upon. function swingSword (e:MouseEvent):void; { //Your code goes here } // “function” is the keyword that appears at the start of every function. // “swingSword” is the name of the function. // “e:MouseEvent” is an added parameter, showing that the function // is called from the event listener. // “:void” is the value that is returned by the function. If no value // is returned, use :void.
Open Flash Professional if you haven’t already. Create a new ActionScript 3 project. [1] X Research source Click the Rectangle drawing tool from the Tools panel. This panel may be in different locations depending on the configuration of Flash Professional. Draw a rectangle in your Scene window. Select the rectangle using the Selection tool.
Find the Properties window. At the top of the window, there will be a blank text field labeled “Instance name” when you hover over it. Name it the same as you did when you converted it to a symbol (“enemy”). This creates a unique name that can be interacted with through AS3 code. Each “instance” is a separate object that can be affected by code. You can copy the already created instance multiple times by clicking the Library tab and dragging the instance onto the scene. Each time you add one, the name will be changed to designate that it’s a separate object (“enemy”, “enemy1”, “enemy2”, etc. ). When you refer to the objects in the code, you simply need to use the instance name, in this case “enemy”.
enemy. x = 150; This affects the position of the enemy object on the X-axis. enemy. y = 150; This affects the position of the enemy object on the Y-axis. The Y-axis is calculated from the top of the scene. enemy. rotation = 45; Rotates the enemy object 45° clockwise. enemy. scaleX = 3; Stretches the width of the enemy object by a factor of 3. A (-) number will flip the object. enemy. scaleY = 0. 5; Squishes the object to half its height.
See this guide for more details on how packages work in Java.
Create a base folder for your project. In the base folder, you should have an “img” folder for all of your art assets, a “snd” folder for all of your sound assets, and a “src” folder for all of your game packages and code. Create a “Game” folder in the “src” folder to store your Constants file. This particular structure isn’t necessary, but is an easy way to organize your work and materials, especially for larger projects. For the simple game explained above, you will not need to create any directories.
If you create a Constants file, it will need to be placed in a folder in your project and then imported as a package. For example, let’s say you create a Constants. as file and place it in your Game directory. To import it, you would use the following code: package { import Game. *; }