Matching Angles
How would i match one mcs angle to another ones
FlashKit > Flash Help > Flash ActionScript
Posted on: 04-23-2004, 06:26 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Converting "flash Angles" To "true Angles"
The bottom line is Flash uses funny angles for _rotation. once you get to 180 degrees, it goes to -179, -178, ..., -1, 0. What I need Is a way to convert these angles into real angles, 0-360.
Anyway, I found a way which seems to work on paper, but Flash says the outcome is not a number:
code:
function fakeToNorm(fake:Number):Number
{
if( (fake >= 0) && (fake <= 180) )
{
norm = fake;
}
if(fake < 0)
{
fake = Math.abs(fake);
fake = fake+(360-2(fake));//This is what Flash doesn't like for some reason
norm = fake;
}
return norm;
};
As I said, I've tried this on paper, and it works fine. Any suggestions would be great.
-ap
Angles
I am trying to work out how to move a movieclip to a location based on its rotation.
The movie clip is a tween of an object moving from
x1,y1 to x2,y2
This movieclip is assigned a random roation value and will then move in the given direction. As the tween of the movieclip completes i need to relocate the movieclip to x2,y2 i the given rotation
Any ideads?
does anyone understand what i am blathering on about?
Stv
Angles...HELP
Hi everyone who is better than me at flash,
Like most people, I am trying to make a breakout game. I got it so that the ball moves, and bounces, and even bounces off the paddle. My problem is this: it will only bounce in one direction. How in God's name do i make it change direction depending on the angle? I've tried everything!!!
Thanks in Advance!
Steve
Angles
hi guys
ok this is the fla and swf
http://digilander.libero.it/magneto1/angle.swf
http://digilander.libero.it/magneto1/angle.fla
now what i want is the car to bounce off the wall and keep moving forward and not going back depending on the angle of collision
obviously if i go straight for the wall i would bounce back on a reverse straight line
hope that makes any sense
thanks
Help Me With Angles
I have some code that is supposed to make my movieclip move based on an angle. pretty simple stuff. I thought . anyway for some reason all it ever does is move straight up and a little to the right (decimal amounts). heres the code. if you could help me it would be greatly appreciated:
PHP Code:
if (this.first != true) {
this.first = true;
this._x = Math.random()*550;
this._y = Math.random()*400;
this.speed = 5;
}
this.dist = 1000000;
for (this.i=1; this.i<=maxfood; this.i++) {
this.tempx = _root["food"+this.i]._x-this._x;
this.tempy = _root["food"+this.i]._y-this._y;
this.tempdist = Math.sqrt((this.xdist*this.xdist)+(this.ydist*this.ydist));
if (this.tempdist<this.dist) {
this.dist = this.tempdist;
this.xdist = this.tempx;
this.ydist = this.tempy;
}
}
this.angle = Math.atan2(this.ydist, this.xdist);
this.x = Math.sin(this.angle*(Math.PI/180))*this.speed;
this.y = Math.cos(this.angle*(Math.PI/180))*this.speed*-1;
this._x += this.x;
this._y += this.y;
if (this.angle>=360) {
this.angle -= 360;
} else if (this.angle<=0) {
this.angle += 360;
}
if (this._x>550) {
this._x = 0;
}
if (this._x<0) {
this._x = 550;
}
if (this._y>400) {
this._y = 0;
}
if (this._y<0) {
this._y = 400;
}
thanx again. cheers
Angles And MCs
Hey, I'm trying to make something in flash 5 where there's a character/ball, and then a quarter-circle which the mouse is constrained to. It works out the mouse's distance from the ball, and the angle too, and then when you click the mouse, it fires it in that direction, with the amount of force specified by the distance.
I can't work out how to get the _x and _y of the ball to move in the right direction. Any ideas?
Ps This is part of the code on the ball:
Code:
radians = Math.atan2(_root.pointer._y-this._y,_root.pointer._x-this._x);
x_mov = this._x-_root.pointer._X;
y_mov = this._y-_root.pointer._Y;
_root.distance = int(Math.sqrt((x_mov*x_mov)+(y_mov*y_mov)));
_root.degrees = int(((radians*180)/Math.PI) / -1);
Thanks
Matt.
[F8] [B]angles?[/B]
Does anybody know how i can convert a normal angle into an isometric angle?
Corresponding Angles
Hi frens,
Thanks to the help provided by some of you experts out there, Im able to do something like tracing back my angle and updateAfterEvent. However, I can only detect 1 angle, which is only half of what I want to achieve.
I have to detect angles made by the diagonal line across 2 horizontal lines, which is corresponding angles.
Please enlighten me, or give me some ideas as to where I should heed to at this moment. Many thanks.
Here is what I have done so far:
Help With Angles
Hi everybody!
I need some help with getting angles, of two movieclips that are on my stage. With instance names: circle1,circle2.
I read that I should use the function Math.atan2 to get the angle, in radians, then I convert it to degrees, but it doesn't make sense, the angles aren't correct.. Here I paste the code I use (its AS not PHP don't know how to add the AS tags):
PHP Code:
_global.Math.degree = function(radians) {return (radians * 180/Math.PI);}trace(Math.round(Math.degree(Math.atan2(_root.circle1._x,_root.circle2._y))));
Any help would be apreciated cheers everybody!
Angles
ok, so i get the math.sin and all the trig stuff. but i cant seem to figure out how to get the angle. the math.atan2(y, x) thing doesnt seem to do it. i think i might be applying it wrong or something so would anyone be able to give me an example of how to use that?
running low on time atm but i'll post the fla for my little attempt at rotating something asap. anyway cheers.
Help With Angles
Hi everybody!
I need some help with getting angles, of two movieclips that are on my stage. With instance names: circle1,circle2.
I read that I should use the function Math.atan2 to get the angle, in radians, then I convert it to degrees, but it doesn't make sense, the angles aren't correct.. Here I paste the code I use (its AS not PHP don't know how to add the AS tags):
PHP Code:
_global.Math.degree = function(radians) {return (radians * 180/Math.PI);}trace(Math.round(Math.degree(Math.atan2(_root.circle1._x,_root.circle2._y))));
Any help would be apreciated cheers everybody!
Help With Angles
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
Angles?
Hello
It seems that it is virtually impossible to find an angle of a movieclip with an origin or some sort of point... I know vamapaull did that on his site where his avatar is facing you all the time. I guess that he calculated how much angle changed from the cursor at the origin of that avatars's location... And rotate that avatar mc to the change of angles... How did he do that?
Is there a class that will handle these angle sort of stuff? Or do we have to go back to our 7th grade algebra textbooks and do stuff like the slope formula, and the point slope formula and all sorts of that Linear Graphing Crap?
Thanks!
Keehun
Finding Angles...
Is there a function in Flash that does inverse tan? I can't seem to find one.
Trig function to find theta angle:
tan(theta) = opposite/adjacent
I need an inverse tan fuction so I can do this:
theta = (inverse tan)(opposite/adjacent)
Is this possible or am I asking too much from action script
Angles, Gravity And The Like
hi im making a athletics game ive sorted the running events, now Im onto the thrown events (ie javlin,shot,longjump)My problem is ive never touched this side of flash before, could anyone suggest any tutorials or reading which could point me in the right direction
Angles N Stuff..
MovieClip.prototype.rot=function(s,d,x,y){
rx=Math.cos(d)*s
ry=-Math.sin(d)*s
this.move(rx+x,ry+y)
}
tis how i place things at angle. the move() function works fine, when i have 45, -45, they line up fine. 180, 0, 360, they seem to be random and all over the place. whats up with this?
Calculating Angles
Hi
I could use some help...
I am trying to calculate a 60 degree angle from a line a-b
Im using flashMX 2004
thanks
Mirrored Angles
I am going to have varies angles and would like to be able to fined the mirrored angle. Example if I have 170 I need to fined 10. or -160 fined -20 and so on. Pleas point me in the right direction.
[F8] A Question About Angles
Hi
I was wondering how i can get the angle of the mouse relative to the registration point of a clip - so that i can rotate the clip to the same angle
can anyone help ?
thanks
[CS3] Angles And Collisions
Hi at the moment I'm working on my physics engine for my new game and I have a problem. To help you understand I drew a diagram.
At the moment I have a hitTest that between a ball and 45 degrees surface.
The ball is travelling at "n" degrees which as shown is in between -180, 0, 180 as shown in the diagram of where the corresponding sides are. What I want to know is what angle should the ball be travelling in after it collides with the surface.
Using 'n' does anyone know of such an equations which would do such a thing?
Please help!
[CS4] Simple Angles
i have a man with a gun and i want that gun to rotate around the shoulder, accoring to the mouse (the gun contains the arms aswell), its registration point is on the left (perfect fit with the shoulder)
im using this
Code:
mousex = _xmouse-this._x;
mousey = (_ymouse-this._y);
angle = Math.atan(mousey/mousex)/(Math.PI/180);
if (mousex<0) {
angle += 1;
}
if (mousex>=0 && mousey<0) {
angle += 360;
}
this.gun._rotation = angle -1;
the problem is it rotates randomly with the mouse, i want it to be able to rotate 360, any ideas how?
thankyou very much!!
Calculate Angles
Hi all,
Im facing a problem with the angles calculation. I searched through actionscript.org and found the AS to calculate angles in relative to the mouse cursor.
That is only part of what I want to achieve. As Im doing a Maths activity, I need to be able to draw the angle that the 2 lines have created. But I have no idea how?
I thought of masking, but is there a better way? As I drafted out, it seems messy. Any ways that AS can achieve? The script is as follows:
There are 2 lines. One is static horizontal, one is an MC called arrow.
onClipEvent (mouseMove) {
trace(this._xmouse);
x=this._xmouse;
y=this._ymouse*-1;
angle = Math.ceil(Math.atan(y/x)/(Math.PI/180));
if(x<0){angle+=180}
if(x>=0&&y<0){angle+=360}
_root.angletext=angle;
_root.arrow._rotation=angle*-1;
updateAfterEvent();}
How do I draw the angle that these 2 lines have created? Hope anyone can give me some enlightenments. Thanks a million.
Angles In A Triangle
Im currently on a project which involves calculating the angles in a triangle. However, there is only 1 pt that is fixed, the other 2 pts are fully draggable, which makes the triangle fully determined by the user.
I have done the line creation and the interactivity, but I have no idea of how to calculate all 3 angles. Another can enlighten me?
Many thanks.
Regards
Angles And Rotation
Just reposting this from Newgrounds.
---
I was tinkering with Denvish' (Newgrounds) follow and shoot with mouse AS. I got the code working right. I decided I wanted the "turret" to slowly rotate towards the mouse, instead of instantly pointing at the mouse. I came up with something like:
if (this.rotation >= angle){
_rotation += 5; //Use PI to calculate and set gun rotation
}
else if (this.rotation < angle){
_rotation -= 5;
}
where:
angle = int((radAngle*360 / (2*Math.PI))+90);
but it wasn't working. It just kept spinning. I decided to trace the "angle" variable, the angles are totally wrecked.
http://www.newgrounds.com/bbs/user_i...88a966f769.gif
It goes what I learned in geometry. Standard angles are supposed to increase from 0 to 360, counter-clockwise starting from the positive x-axis. But WTF at this? I know it starts at positive y-axis because I drew it that way, but does it suddenly print -90 after 271 degrees?
Problems With Angles
I'm new to flash and I was trying to make an artillery game. At the bottom of the screen I want my tank with a cannon attached to it to shoot. I don't have have a problem shooting bullets straight up, but I want the cannon to shoot at different angles. Say... for instance... it's facing straight up right now, which I would assume would be 90 degrees... but I want the cannon to be able to rotate and shoot at a full range of directions.... say... 180 degrees through 0... I use the _rotation command to rotate the graphic turret itself, but I wasn't sure how to change the direction of the bullets coming from the cannon. I understand flash works on a grid. So under my bullet class I have i set a variable to do _y += -5 to make the bullets fly straight up. But when i try to change the angle by adding _x += (some number) it changes the angle but also the speed.... I want the speed to be a constant value throughout. Am I going to have to break out the old trig book or is there a simpler way for me to do this?
I wanted to use the up and down arrows to adjust the angle... Not a mouse cursor to target and aim..
- Paul
Angles And Calculating
Hi there,
i'm racking my brain on how to do this and haven't found a solution yet.
Anyways, i was wondering if anyone can give me some pointer son how to do this.
i have a dial that sets the angle on which i want an object to move. I get the angle in degrees (example -145) which would move the object to the bottomleft.
I've set up a boundary on my canvas and i want to know on which coordinates the object would intersect with the boundary according to the angle of movement.
so is there anyway to extrapolate a set of starting coordinates (say 309/372) according to the angle and know where the intersection would be.
I don't graps how i'm supposed to use the rotation angle to see where the object would intersect with the horizontal or vertical limit of the boundary.
any help would be greatly appreciated,
Wesley
Angles And Distances
has anyone here ever shot the staple out of stapler?
well i need that kind of effect for my game
staple goes really fast our of the stapler, then falls down
how can i do that with action script?
Mirrored Angles
I am going to have varies angles and would like to be able to fined the mirrored angle. Example if I have 170 I need to fined 10. or -160 fined -20 and so on. Pleas point me in the right direction.
Sword Angles
OK cant figure it out (not a math guy) so what I got is a circle (represented as the character) which moves around with the arrow keys, then i have a line (representing the characters would be sword) which is controlled by the mouse and is contrained ina rectangle around the body. The problem is this, how do i know how far to adjust the sword._rotation to make it always point straight away from the body?
Angles With Actionscript
Hi
i wonder if someone can help
i'm sorry, i'm pretty new to flash, but someone wants me to make a program where there is a horizontal line and a vertical line.
the user should be able to "grab" the top of the vertical line, and move it around, the bottom of the line should be snapped to the horizontal line, and a text box will display the angle between the two...
any ideas?
i have a rough idea but i've never done anything with angles before...
thanks
tom
Rotation And Angles
In a pool game i am making, i need to make a cue movieclip rotate 360 degrees around the "whiteball" and then when a key (space) is pressed the "whiteball" travels along the angle the cue is facing....i vaguely remember doing this a year or so back in Director but cant find the source code for it. Im sure it's pretty easy to do any help would be greatly appreciated!!!
Heres my .fla file so far....
http://www.mediafire.com/?ad1h4jxezy3
Thanks for any ideas!
Angles In Radian
i am kinda confused with this... i know in flash left top is 0,0 making flash stage as +ve quadrant. how do angles are measured in flash ( in rads i believe ??) ....
i mean if you draw diagram showing directions as on maps, how many radians will be at position east ? west ? north ? south ??? ......how do i say if mouse is clicked in northeast quadrant or NW or SE or SW quadrant ???
Velocity And Angles
Hi atm I'm writing the code for a game. I can sorted Vertical and Horizontal collision. But I'm having trouble with collisions at an angle, e.g. a 45 degree ramp. My cousin says I have to work out the trajectory angle from the Xv and Yv but the closest I can get is:
PHP Code:
playerRadins = Math.atan2 (speed_y, speed_x); playerAng = Math.round(playerRadins * 180 / Math.PI);
This gives me something along the lines of this.
And I'm looking for this:
Please help also if there is another way to do this just with velocity vectors please tell me how to do that instead. I think this can did it that way:
http://www.tonypa.pri.ee/vectors/tut06.html
but I can't make head nor tail of it
Heres what I have so far:
http://img99.imageshack.us/img99/959...2scrolliz7.swf
Camera Angles
ok, anyone know how to do a 360 view on an object like they did in the very beginning of the Matrix where trinity is put into bullet time and does a 360 then kicks the guy? how do you do it on flash
Pentagon With 2 Right Angles?
hi,
CAn anybody help me how to go about drawing a pentagon which will have 2 of its angles to be rectangle.
thanks
saumya
Circle Collisions And Angles
i want to make a flash movie where you are dragging a movieclip and when it detecs collision with another movieclip, the 2nd clip will bounce off at the correct angle. I'm so stumped. Ihave used hitTest to see if the two clips collide, but don;t know how to make the other one move. Can someone help me out?
thanks
kev
Changing Camera Angles
How does one change the camera angle. I have seen some movies where the creator has an object and while I watch the movie. Certain scenes give the illusion of the camera rotating 360 degrees around the object. How is this done where can I find out how to do this
Changing Camera Angles
How does one change the camera angle. I have seen some movies where the creator has an object and while I watch the movie. Certain scenes give the illusion of the camera rotating 360 degrees around the object. How is this done where can I find out how to do this
Finding Angles On A Triangle
I'm trying to asign a value to the _rotation of an MC based on it's trajectory. Insted of confusing everyone with a bad discription of what I need, theres a picture of it here: http://www25.brinkster.com/nippashish/triangle.html
It's preaty self explanitory, what Im basicly looking for here is a formula.
Mouse Angles (Trig?)
Alright Im having a little problem figuring how to have a movie clip (Circle with a radius) move depending on where the mouse is located. The radius is supposed to follow the mouse. Sounds like simple trig but is there an easier way and/or can i get some help with the code?
Key.Down ~~ Different Angles For Weapon Fire
I'm just wondering how to get the weapon to fire on the 4 differnt angles (up, down, left, right) with a object that changed with key stokes Key.UP, Key.DOWN, Key.LEFT, Key.RIGHT.
So that when i hit up, it shoots a object upward, not like current, left across the screen.
Object with weapon script:
PHP Code:
onClipEvent (load) {
speed = 8;
_root.laser._visible=false;
laserCounter=1;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
gotoAndStop(1);
this._x+=Speed;
} else if (Key.isDown(Key.LEFT)) {
gotoAndStop(2);
this._x-=Speed;
}
if (Key.isDown(Key.DOWN)) {
gotoAndStop(4);
this._y+=Speed;
} else if (Key.isDown(Key.UP)) {
gotoAndStop(3);
this._y-=Speed;
}
if (Key.isDown(Key.CONTROL)) { laserCounter++;
_root.laser.duplicateMovieClip( "laser"+laserCounter, laserCounter );
_root["laser"+laserCounter]._visible=true;
}
}
Ammo:
PHP Code:
onClipEvent (load) {
laserMoveSpeed=20;
this._y=_root.char._y+22;
this._x=_root.char._x+16;
}
onClipEvent (1) {
this._x+=laserMoveSpeed;
if (this._x>600){
this.removeMovieClip();
}
onClipEvent (2) {
this._x-=laserMoveSpeed;
if (this._x<600){
this.removeMovieClip();
}
onClipEvent (3) {
this._y-=laserMoveSpeed;
if (this._y<600){
this.removeMovieClip();
}
onClipEvent (4) {
this._y+=laserMoveSpeed;
if (this._y>600){
this.removeMovieClip();
}
}
Camera Angles, Zooming.
can anybody give me some hints or tutorials on how flash animation changes its camera angles (zooming, ala-matrix fx)
thanks.
Collision Detection At Angles
I have played around with some basic collision detection and made an animation with a ball bouncing between two walls using this as:
code:
onClipEvent (enterFrame) {
move = this._x;
if (numval == 1) {
this._x = move-5;
}
if (numval ==2) {
this._x = move +5;
}
if (this, hitTest(_root.block)) {
numval = 1;
}
if (this, hitTest(_root.block2)) {
numval = 2;
}
}
obviously i could replicate this easily enough on the _y axis with 2 new walls etc but what if the ball was moving at say a 45 degree angle and i wanted it to bounce of the wall using this angle? I know this is in the realm of math but could anyone get me started or point me in the direction of the relavant functions/equations.
Thanks.
Detecting Angles And Utilizing Them
Ok, so essentially i have an object that you move left and right, and i have enemies at the top (object is at bottom). WHat i want and have been trying to figure out is: i need the enemies to shoot, so i look for some tuts and find nothing, then i find a game that is diong the exact thing i wanted to do and i found that game here: http://ebiz.terry.uga.edu/~dpopov/Flash/Galaga.html
i need to be able to figure out the angle of ur object in comparison to the ships, and then somehow use that to shoot a bullet out of the enemy ship, and follow the angle towards your ship when the angle was taken, i have no clue how to do this and was wondering if any one could help, i have a pretty good understanding of many concepts of flash actionscript, but cant figure out how ti use the angle (and find it) and then make the bullet spawn and follow the path, thanks for any help
Angles In An Isometric World?
Flash 8
Does anyone know how i would be able to make a movieclip rotate with the mouse in an isometric view?
Thanks for your help!
[f8] Angles And Projectile Motion
Hello everyone!
I need to make a script where an object behaves like in the attached image, where I tried to illustrate that I need to set the direction/power of the jump with the mouse and an scalable Arrow MC.
I've seen it on so many places on the internet but I can't seem to find anything relevant on now... And google doesent helped me a lot on this
can please somebody point me in the right direction?
TNX a bunch guys!
Ovidiu
[CS3] Vector, Angles, And Collisions
Hi atm I'm writing the code for a game. I can sorted Vertical and Horizontal collision. But I'm having trouble with collisions at an angle, e.g. a 45 degree ramp. My cousin says I have to work out the trajectory angle from the Xv and Yv but the closest I can get is:
PHP Code:
playerRadins = Math.atan2 (speed_y, speed_x);
playerAng = Math.round(playerRadins * 180 / Math.PI);
This gives me something along the lines of this.
And I'm looking for this:
Please help also if there is another way to do this just with velocity vectors please tell me how to do that instead. I think this can did it that way:
http://www.tonypa.pri.ee/vectors/tut06.html
but I can't make head nor tail of it
Heres what I have so far:
http://img99.imageshack.us/img99/959...2scrolliz7.swf
Rotation In 3D: Euler Angles
I have been experimenting with 3D for the past little while... I had started out in AS2 and have since moved to AS3 with few problems.
I included a .zip with two swf files demonstrating my problem. One of them (3d rotation z x and y (mouse).swf), the example I'm talking about, shows the problem. Try moving your mouse to one of the corners of the swf and watch the resulting rotation. The objects don't rotate as you would expect them to.
The other swf shows another example of rotation in 3d. This one changes the location of the points in every frame, and so you cannot go back to the initial rotation. The upside is that it rotates exactly like you would expect it to: It sort of 'rolls' toward the cursor. I need to be able to get to the initial rotation because the points inside the circle need to rotate around the circle.
So I searched around for what might be causing this odd rotation, and I found out that it is caused because of the fact that if you rotate something along one axis, the other two axes change as well.
Did some more searching around and found something called Euler Angles. (http://en.wikipedia.org/wiki/Euler_angles)
This is a method of 3d rotation which can have 12 rotation combinations... x y and z rotations all either relative to the original axes of rotation, or relative to the new rotation.
This would work perfectly for my purposes. The z rotation needs to be relative to the rotated object, and the x and y need to be relative to their original axes.
The problem is how do I do this. I've inspected the Wikipedia page and have come up with nothing. The math is either too complicated or I wouldn't know how to do it in flash.
If ANYONE at all can help me out with this in any way, I would really appreciate it.
Thanks in advance,
Mavrisa
Math Questions Regarding Angles
Hi there.
I need quite some help, I am afraid. I've tried this and that, and everything comes out wrong.
I want to shoot a object within the angle [Straight Up] to [All Left].
_| within this and to the left.
How can I set a random angle within these rules, and calculate the speed of both x-value and y-value?
I appreciate the help
| Samuel
|