Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with angles

Status
Not open for further replies.

xsublimefrekx

Technical User
Jun 21, 2006
3
0
0
US
Hey guys im trying to make a game like tank wars. I am having trouble figuring out how to get the angle to change. I want to be able to press "q" to raise the cannon and "a" to lower the cannon. Any help would be amazing
Thanks
 
I assume the tank gun is a movieclip. Now make sure the movieclip rotate point is at the end of the gun. Do this by selecting your movieclip, pressing the letter Q and then moving the rotate point, which should be the circle currently in the center of the movieclip to the roate point desired.

Then in actionscript you can set the rotation about that point with

gun_mc._rotation = -15;

this rotates the clip around the rotation point in a counterclockwise direction.
 
i got that to work. I am now having a problem getting the bullets to arch once leaving the gun
 
they are going to be random depending on the speed and angle of the player
 
If you can come up with a formula for the trajectory, then you can write a function that triggers on the onEnterFrame event and have the formula continually update the bullet's _x and _y properties until the bullet hits its target.

onEnterFrame = function(){
<your trajectory code here>
}

Once the bullet hits be sure to delete the onEnterFrame function, so it doesn't continue to run.

delete onEnterFrame;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top