SmashCam Class

June 18th, 2008

This Actionscript 3 class is very useful for just about any game you are developing in Flash. I made this "SmashCam" class based off of Colin Moock's vCam. I was really impressed by what it can do for animators in Flash and it inspired me to use it for developers who make Flash games. The vCam isn't really complicated a script, it is very straight forward - its a real clever script on how to use a movie clip as a camera. Let me show you what the script does in action, move the blue circle with arrow keys around the stage.

The SmashCam is actually set right now to focus and maintain the square and circle in the center of the stage as the two movie clips move around and about. But in this example only the blue circle is moving. The green painted clouds on the stage are there to help you see that blue circle is moving and the stage is enlarging and shrinking to the affect coming from the SmashCam.

I won't go into too much detail on how to setup the .fla to have the circle move around stage, since that tutorial is in my last post, but I will show how to set up the SmashCam. This is what is you need to do:

Actionscript:
  1. // SmashCam(display_container:MovieClip, target1:MovieClip, target2:MovieClip, [width:int = 600, [height:int = 450]]);
  2. var camera:SmashCam = new SmashCam(this, Circle, Square);

Thats it. The SmashCam takes three required parameters, the display_container,target1,target2, and two optional parameters width and height (the default width is 600, and default height is 450). You can also set up the SmashCam's minimum and maximum width and height of how far it should scale the display_container like so:

Actionscript:
  1. camera = new SmashCam(this, Circle, Square, 550, 400);
  2. camera.min_width = 200;
  3. camera.min_height = 150;
  4. camera.max_width = 2000;
  5. camera.max_height = 1500;

All that is left to explain is the calculation of the SmashCam executed every frame. To do so, in the main game loop add this line of code:

Actionscript:
  1. camera.calculate();

I will let you do the rest of the experimenting and looking into of what the SmashCam Class is really doing. I appreciate any feedback on improvements or better alternatives. Or if you have questions, I will do my best to explain. Thanks and have fun!

SmashCam class download

AS3

RPG Character Movement – Part 1

June 13th, 2008

Today I am going to share a small sample of RPG type character movement using Flash Actionscript 3. I will say up front, this sample will look very boring, but this tutorial is for Actionscript 3 beginners. However, I will continue to build examples and more tutorials off this one. I also would like to point out that I will be writing this code in the main time line, which is something you should try not to do in Actionscript 3. So why am I writing the code on the main time line? In honesty, this is how I begin to program in Actionscript 3 to help understand the newer syntax and different structure and event handling and everything Actionscript 3 has to offer from Actionscript 2. I also would like to point out that I am not going to discuss all the syntax throughly (for the most part, but I will try my best), because if you want to program games, you will have to do some research and testing on "hows" and "whys" and "what the...?".

So lets begin with the sample of what you will have by the end of this tutorial:

Read the rest of this entry »

AS3 > Games > RPG