Here's test 2. Play with the numbers again. I got it right this time. Angle Test 2Code:onEnterFrame = run; deg2rad = Math.PI/180; rad2deg = 180/Math.PI; delay = 7; timer = 0; function run() { timer++; if (timer%delay == 0 && Key.isDown(Key.CONTROL)) { fire(); } dx = _xmouse - _root.spawn._x; dy = _ymouse - _root.spawn._y; xd = spawn._x-_root._xmouse; yd = spawn._y-_root._ymouse; rot = Math.atan2(yd, xd); angle.text = rot*rad2deg+180;; } function fire() { bc = Number(_root.bullets.text)-1; sa = Number(_root.spreadAngle.text); st = bc * sa; sp = st/2; s = 90 + sp; e = 90 - sp; for (var i = s; i>=e; i-=sa) { var ang = i; ang *= deg2rad; var b = attachMovie("bullet", "b"+getNextHighestDepth(), getNextHighestDepth()); b.xc = 10*Math.cos(ang); b.yc = 10*Math.sin(ang); b._x = spawn._x; b._y = spawn._y; b.onEnterFrame = function() { this._x += this.xc; this._y += this.yc; if (this._x < 0 || this._x > Stage.width || this._y < 0 || this._y > Stage.height) { this.removeMovieClip(); } } } } stop();
You can see an example of a variable pointing angle by replacing the start/end variable lines withThen hold Control while you move the mouse.Code:s = (rot*rad2deg+180) + sp; e = (rot*rad2deg+180) - sp;




Reply With Quote