ActionScript: Throw bullets to mouse direction

Share

After calculating the angle of 2 graphic objects, you can also use this angle to throw a bullet to the object direction with the trigonometry. How ? Calculating the angle (in radian) between 2 graphics objects with the Math.atan2 method (cf. Orient object to the mouse cursor). On click, display a bullet to the “tank” [...]

Posted on Monday December 27th, 2010 at 12:50 PM by admin · Permalink · 6 Comments
Share

In: ActionScript3 as3, Game Design, Tip, Tutorial · Tagged with: , , , , ,

ActionScript: Orient an object to the mouse cursor

Share

How to orient an objet to an other ? Just put those lines and change the instance name myTank. 12345678910111213141516// This object will always look at the mouse cursor myTank.addEventListener(Event.ENTER_FRAME, tankEnterFrame); // This function will be launched every frame (25 times by seconds); function tankEnterFrame(pEvt) {   [...]

Posted on Saturday January 9th, 2010 at 06:17 PM by admin · Permalink · Leave a comment
Share

In: ActionScript3 as3, Game Design, Tip, Tutorial · Tagged with: , ,