This is the second step in my series of tutorial, the first being Easy Keyboard Controls and Game Design. In this tutorial I will be building on what we already have, adding asteroids and the ability to crash into them.
In this tutorial I will be going over some of the basic elements to making a game in Flash. This being the first in a short series of tutorials on the subject, I will cover the main game loop and keyboard controls.
I have another simple but neat, little tutorial here on Flash CS3 filters. This time I’m not using Tweens at all. Our effect is going to use the MouseEvent.MOUSE_MOVE event to create the illusion of a light source coming from our cursor.
Above is a little example menu I made for a fake game called “Top Secret.” Don’t expect a game to start when you click on the Play button. Instead, when you click a button you will get a little menu to change the rollover effects of said button.
What I’m going to be talking about for the next… however long you read this, is how to recreate these cool effects for your own projects. Hopefully you will come up with some better ideas for using filters then just rollover effects.
For any dynamic Flash project, XML will be a powerful tool. One of the most common examples (and one of the simplest) is a picture gallery like the one I have here:
I’ve talked about the basics of Box2DFlash v1.4.3 in my Introductory tutorial. I showed how to create your world and how to introduce simple bodies into that world. With the release of Box2DFlash v2.0.0 the basics remain mostly the same, there are a few details changed. I need to go over these small changes before I move on to the next step of adding joints and forces to the bodies.
The first and biggest change (although really a small thing) is that we no longer work in pixels! We now work in units that by default equal 30 pixels to 1 unit (think of it as meters; 30px : 1m). With this change our normal gravity is no longer (0, 300) but instead (1, 10). This makes more sense to me at least because gravity in reality is 9.81 m/s/s. This is going to effect almost everything you do, from applying forces to setting the width and height of a box.
Box2DFlash v2.0.0 was finally released on the 17th of this month (April). Box2DFlash is the Flash AS3 port of Erin Catto’s C++ physics engine Box2D. Erin Catto is a physics programmer at Blizzard Entertainment (WarCraaaft!). I’ve been looking forward to this release since I found out about it while making a tutorial for the previous release (v1.4.3) about a month ago.
Music Credits:
Title: The Best Day Ever
Artist: SpongBob
Album: The SpongeBob SquarePants Movie: Music From the Movie and More
Creating an MP3 Player in ActionScript 3.0 is fairly straight forward. The complexity varies greatly depending on what kind of features you want your player to have. I don’t plan on getting into ID3 tags here, but otherwise (as you can see) I will be going over the full functionality of a normal MP3 Player.
I’m going to walk through the steps of making a preloader for your animation, game, or application and provide easily implemented source files that you can copy and change to fit your own project. Making a preloader in ActionScript 3 is more difficult to figure out then it was in ActionScript 2, but the code itself is not any harder.
In celebration of our little vector contest I thought I would unofficially submit my own entry.
I made this animation using our Spring Time vector pack. It’s about 360Kbs, but once it’s loaded click Play to get it started, then you can press the Left or Right arrows to control the little bunny.
I’ll walk you through the process I went through to create this here game/animation.
After writing my introduction tutorial to Erin Catto’s Box2D AS3 physics engine port, I found out that I was writing about version 1.4.3. Well a new version (v 2.0.0) is set to come out within the next few weeks, so I thought that I would put off any more tutorials on Box2DFlash till I find out what has changed.
Until then, I’ve found a bunch of fun games made with the Box2D engine and I thought I would share them with you.
I wanted to try something fun with Flash this week, so I did a quick search for “Flash Physics Engine.” Lo and behold, I struck gold. Box2DFlashAS3 is an open source ActionScript 3.0 conversion of the C++ Physics Engine Box2D. I’m very impressed with its well coded structure and easily implemented nature. I learned a few new things that will change how I code forever just by reading through their example files.
Still, they have limited resources right now as far as help documentation goes (”Please refer to the source code from the examples provided to get an idea of how to use Box2DFlash in your projects.” — that’s the ReadMe.txt that comes with it… not very helpful,huh). I thought I might give you an example of my own and walk through it step by step.
I am going to talk about how to animate using Tween objects in ActionScript. Tween objects are enormously useful. They can change any numeric property of any object over time.
For example one of the most common uses of Tween objects in ActionScript is to fade an image out as another fades in. The advantage of using a Tween object to do this instead of any of your other options is
1.) it is easy to understand
2.) it is the easiest to code
3.) it generally looks the best.
It’s fairly easy to write a bit of code that will change the X position of a movieClip by 2 every frame, but that will be very linear and boring. Also when does it stop? and how? You would have to create a lot of if() statements that just take forever to think through and would make your code harder to read. (VQ:lots of nested if statements are usually a thing to avoid)
With a Tween object you can use Easing methods. In the example that follows I used the Easing method Regular.easeInOut to start the motion with a little acceleration and then bring it to a stop in the same way.
If the motion of the dot gets annoying you can stop or start it again at any time by clicking on the Flash movie.
I’m going to talk about how to build a simple 4 function calculator using static variables and meathods in Flash ActionScript 3.0. This is my first tutorial, so if you have questions or comments, I would appreciate them and will do what I can.
As a designer you might be really excited about the power Flash CS3 has to offer you, but a little frustrated with the complicated ActionScript required to turn your vision into reality. Or maybe, as a Flash developer you are getting hung up on the difficult transition from ActionScript 2.0 to AS 3.0. Well, it’s my job here to try and help you through that learning process.
I’m going to be trying to post a new ActionScript 3.0 tutorial once a week (and maybe some AS 2.0 tutorials if requested) every Monday. If you have any specific requests or questions you can ask them in a post comment or send me an e-mail at Paul@ClickPopMedia.com. If you are looking for more immediate answers there is a great resource for ActionScript help at ActionScript.org. You might see me answering questions in their forum (as TomMalufe) or see some of my tutorials posted there.