• Home
tudwaythecore.com
blog
  • Recent Posts

    • Detecting focus in flash player
    • BitmapData PerlinNoise
    • Creating bridges in APE part 2
    • Creating bridges in APE
    • SteerWheels 2
    • Creating a simple APE example
    • Design me some levels!
    • Finished Migrating
  • Recent Comments

    • tudway on Creating a simple APE example
    • tudway on creating a platform game in as3 part 4
    • venu on Making a Shooting Game in AS3
    • chris on creating a platform game in as3 part 4
    • Kronoshifter on Creating a simple APE example
  • Categories

    • APE
    • flash
    • game
    • platform
    • sound
    • tutorial
    • Uncategorized
  • Archives

    • May 2009
    • October 2008
    • September 2008
    • August 2008
    • May 2008
    • April 2008
    • March 2008
  •  

    August 2008
    M T W T F S S
    « May   Sep »
     123
    45678910
    11121314151617
    18192021222324
    25262728293031
  • games

    • Game Showcase
Aug 27

Notice

Uncategorized No Comments »

Just to let you know that in some of the old posts that i made ages ago, the flash files don’t load. This is because the servers i chose to host them on then have gone down since i first uploaded them. I will try to update the location of the flash files, but i am pretty sure that  i no longer have the .swf files for the create a platform game posts. I only have the latest, which i have already updated. 

Sorry for any inconvenience, i will get this fixed as soon as possible and this will take priority over any new posts in the making.

Aug 27

Rotating a movieClip to face the mouse

flash, tutorial 1 Comment »

This is one of the first things that i tried to do in flash when i first got mx. now i will explain how to rotate a movieClip to face the mouse in adobe cs3.

To start off you can either draw the object that you want to rotate on the stage, or make it entirely in actionscript, as long as its a movieclip with an instance of it on the stage it will work.

First i have to create the object i am going to rotate. i am going to do it in actionscript with the built in drawing API.

I will explain the drawing API in greater detail in a later tutorial. But this code will make a turret shaped movieclip.

turret.graphics.beginFill(0xFFFFFF);
turret.graphics.lineStyle(2, 0xFFFFFF);
var turret:MovieClip = new MovieClip();
turret.graphics.drawRect(-10, 0, 20, 40);
turret.graphics.endFill();
turret.graphics.beginFill(0xFFFFFF);
turret.graphics.drawCircle(0,0,20);
turret.graphics.endFill();
turret.x = 275;
turret.y = 200;
addChild(turret);

 
Ok now to explain the code;

line 1: This introduces a new variable called “turret” which is a movieClip. We can now use the instance “turret” to give it commands.

line2: Using the movieClip.graphics method i am telling the turret movieclip to start a fill colour which is white. the “0xFFFFFF” is a colour hex code. 6 Fs means white.

line 3: This is setting the linestyle of the movieClip to 2 pixels thick and then its colour, again white.

Line 4: This line draws a rectangle in the movieClip instance, the first number is the x coordinate, the second is the y coordinate, the third number is the width and the last number is the height. If you want the object to have dynamic actions applied to it it is best to set the x and y coordinates to 0.

line 5: Telling the movieClip to stop filling in with the colour.

line 6: Setting a new fill, with the same colour as before. If i hadn’t ended the previous fill then part of the movieClip would be transparent.

line 7: This command “drawCircle” does exactly what it says, it draws circles. the numbers are x then y coordinates and then the radius of the circle. The coordinates are set to 0 because we want the turret to rotate about its centre.

line 8: Ending the circle fill colour.

line 9-10:These are setting the x and y coordinates of the turret, these can be anything but i’ve set them to the centre of the stage.

line 11: This is probably the most important line. It adds the movieClip instace to the stage so that we can see it!

Copy these actions in your actions panel and set the background colour to something other than white. I have used black. It should look exactly like this.



 

In the next part of the tutorial we will make it actually rotate.

Powered by WordPress .::. Designed by SiteGround Web Hosting

cssandhtml