Forum Topic: Programming Problems!

(91 views • 5 replies)

This topic is 1 page long.

<< < > >>
Sad

iloveicelollies

Reply To Post Reply & Quote

Posted at: 11/4/09 01:48 PM

iloveicelollies DARK LEVEL 07

Sign-Up: 03/07/09

Posts: 56

I need help. Using AS2, does anyone know how to aim and fire with a weapon such as a gun. Also, I have the aiming part settled, however when the gun is aiming to the right it is the right way round, but when the gun is aiming to the left it is upside down...

This is the code I used on the gun; and yes, it is going to be a madness game:
onClipEvent (enterFrame) {
myRadians = Math.atan2(_root._ymouse-this._y, _root._xmouse-this._x);
myDegrees = Math.round((myRadians*180/Math.PI));
_root.yChange = Math.round(_root._ymouse-this._y);
_root.xChange = Math.round(_root._xmouse-this._x);
_root.yMove = Math.round(_root.yChange/20);
_root.xMove = Math.round(_root.xChange/20);
this._rotation = myDegrees+90;
}

And for the firing of the gun, I need it so that it fires when I click the mouse...most appritiative if you could help me.

I am a goat, from the future, with tazor beams, and tuna; lots and lots of tuna...

BBS Signature

None

Treerung

Reply To Post Reply & Quote

Posted at: 11/4/09 02:07 PM

Treerung DARK LEVEL 11

Sign-Up: 04/18/08

Posts: 571

To fix the gun being upside down you should implement _yscale into your code.

:'(

BBS Signature

Questioning

iloveicelollies

Reply To Post Reply & Quote

Posted at: 11/4/09 02:14 PM

iloveicelollies DARK LEVEL 07

Sign-Up: 03/07/09

Posts: 56

At 11/4/09 02:07 PM, Treerung wrote: To fix the gun being upside down you should implement _yscale into your code.

How though? Please could you fix the AS2 script for me, then I would know what you are on about...

I am a goat, from the future, with tazor beams, and tuna; lots and lots of tuna...

BBS Signature

None

hdxmike

Reply To Post Reply & Quote

Posted at: 11/4/09 02:30 PM

hdxmike LIGHT LEVEL 09

Sign-Up: 09/11/09

Posts: 1,824

If the gun rotation is within a range of degrees on the left/right _xscale *= -1 and vice versa

OOP AS3 || Flash 8,CS3,CS4 || *sigh* || The new forum on the block : FLASH SEED !

BBS Signature

Happy

iloveicelollies

Reply To Post Reply & Quote

Posted at: 11/4/09 02:50 PM

iloveicelollies DARK LEVEL 07

Sign-Up: 03/07/09

Posts: 56

At 11/4/09 02:30 PM, hdxmike wrote: If the gun rotation is within a range of degrees on the left/right _xscale *= -1 and vice versa

What?

I am a goat, from the future, with tazor beams, and tuna; lots and lots of tuna...

BBS Signature

None

Kart-Man

Reply To Post Reply & Quote

Posted at: 11/4/09 03:05 PM

Kart-Man NEUTRAL LEVEL 27

Sign-Up: 01/07/07

Posts: 3,735

At 11/4/09 02:50 PM, iloveicelollies wrote:
At 11/4/09 02:30 PM, hdxmike wrote: If the gun rotation is within a range of degrees on the left/right _xscale *= -1 and vice versa
What?

Create a variable that stores the movie clip's _xscale, then have the movie clip's _xscale equal the negative of your variable (simulating flipping).

var scale:Number = _xscale;
if (_rotation > 180) {
_xscale = -scale;
}else{
 _xscale = scale;
}

Something like that, anyway.


All times are Eastern Standard Time (GMT -5) | Current Time: 03:21 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!