Archive for the ‘Actionscript 3.0’ Category

Elasticity

Thursday, March 20th, 2008

Both my games Zwingo and Squidgy use elasticity for the main control. Elasticity is the effect of making a MC follow the mouse while keeping it’s momentum if the mouse stops. Picture holding a yoyo on a string, looking straight down on it and moving the yoyo about. View the example here.
Elasticity SS1

Create a circle on the stage and convert it to an MC, instance name ball. Add the following code to the main timeline:

The variables we set are xspeed, yspeed, fric (friction) and ease. Alter these later if you want.

Each frame we add the difference between where the ball is and where it needs to go divided by ease on to the speeds. We then multiply the speed by friction, in other words friction has an effect on the ball. Finally we relate this speed to the ball’s properties, and the effect is complete.

Say at first, xspeed = 0, the difference from the mouse to the ball is 100. This means the resultant speed is (0+100/10)*0.9=9
The next frame, xspeed = 9, difference = 91 so resultant speed is (9+91/10)*0.9=16.29
As you can see, as the ball gets closer (difference gets smaller), the speed increases. Now lets see what happens when the ball passes the target:

xspeed = 20, difference = 0, so resultant speed is (20+0/10)*0.9=18
Then xspeed = 18, difference = -18 (the ball has passed to the other side), resultant is (18-18/10)*0.9=14.58

Now that the ball has passed the target, it starts to slow down.

Simple Shooter Game - Part 1

Tuesday, March 18th, 2008

shooter ss2

This set of tutorials with take you through the basics of how to create a simple shooter game. Note that this is the way I do it, not the only way, and feel free to change things as you read as every game maker has a different style. The first part of the tutorial will show you how to make the main player and how you can control it. This tutorial is done completely is Actionscript 3.0, so if you only know AS2, see this post and if you don’t know actionscript at all, go here.

The first step is to draw the main character. We’re going to be controlling him using the WASD or UP, LEFT, DOWN, RIGHT keys to move him, the mouse to aim and mouse click will fire bullets. This is what you’ll be able make after you do this part. After you’ve drawn the character, put it on the stage and give it an instance name of ’ship’.

Now add this code to the main timeline: (more…)

Converting from AS2 to AS3

Monday, March 17th, 2008

This post should help you convert from Actionscript 2.0 to 3.0. AS3, in my opinion, was the biggest jump for Adobe from Flash 8 to CS3. It’s shown to be heaps faster than AS2, with a whole new bunch of classes and features. I won’t teach you everything there is to know, this is just a small step for you if your facing this dilemma. If know nothing about AS2, don’t bother reading.

Firstly the properties are represented differently, there is no more underscore when you are setting properties:

The next thing you need to notice is that you can no longer add code to movieclips directly on the stage, all coding is now done from the timeline. Also, no more using ‘_root’.

If you are not already into defining variables or classes properly, AS3 forces you to do this or an error occurs. This is the correct format:

A big difference in AS3 for game development is the use of event listeners. Now, instead of calling a function like ‘onEnterFrame’, you create a custom function that will execute on the event, then add an event listener to the MC you want the event to listen to. Here’s a quick example with the enter frame event: (more…)

New Blog, Cursor Effects

Saturday, March 15th, 2008

Hey, welcome to my new blog!

This new blog will make it tons easier for me to keep you posted on news from Kabomb, as well as flash related news from around the web. I’ll also be able to post open source tutorials, prototypes, and flash experiments that you can follow. You’ll be able to comment on all my posts and I’ll try to reply to the ones that need a reply, if not just email me.

If you have no idea what flash is or you want to get into it, you can download a free trial from the Adobe Website where you’ll also need flash player (you should already have it) to see all the examples on your web browser.

Okay, let’s get down to business - my first tutorial - Cursor Effects. This lets you create effects like those in my Cursorized series where MC animations continually come out at the cursor which creates a really cool effect.

Here’s what I did.
Cursor Effect Screenshot

Now I’ll explain how I did it.
(more…)