Angle Wont Work?
hi, iam using this to point to a food mc for the male mc to go and eat but he is not pointing in the right direction?
i even made the mc pointing to the right?
distancex = (_root[foodies]._x)-(this._x); distancey = (_root[foodies]._y)-(this._y); var angle = math.atan2(distancey, distancex); this._rotation = Math.PI/180*angle;
cheers
FlashKit > Flash Help > Flash ActionScript
Posted on: 11-09-2004, 01:21 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Getting An Angle
I have a helicopter and when you click with the mouse cursor, it adds another helipad, the helicopter starts at the first helipad and flies towards the next one in the array, so when you click, it adds another destination to the list. My problem, I want the helicopter to fly with it's tail to the back, getting the direction iut has to fly and then rotates it aacordingly, anybody that can help me???
it can be previewed at http://subman.deviantart.com
Check the helicopter chaos, this is the flash I'm having difficulty with..
Just click on the helicopter link, thanx for th einput in advance
Arc On An Angle
Hi,
Angles are drawn dynamically. They are measured and shown to users. I'm stuck on making arc for the angles drawn dynamically.
Any links, idea or help?
Angle
I have a two boxes center screen I did action on both as follows
onClipEvent (enterframe) {
_rotation-=2;
_x++;
_y++;
}
The first rotates up to far left corner 2nd bottom right corner.
onClipEvent (enterframe) {
_rotation-=2;
_x--;
_y--;
}
My quest is how would I get a 3rd + 4th box going opersite directions, Many thanks
Regards Barrie
Angle Between Two Mc's
hey
trying to calculate angel between two mc's
came up with this
ActionScript Code:
function angle(ob1, ob2) {
var o1 = eval(ob1);
var o2 = eval(ob2);
xDist = o1._x-o2._x;
yDist = o1._y-o2._y;
return (Math.atan(yDist/xDist)*180/Math.PI)-90;
}
but there seems to be something wrong with that
its only returning negative angels
any ideas whats wrong with it?
Angle
I have a two boxes center screen I did action on both as follows
onClipEvent (enterframe) {
_rotation-=2;
_x++;
_y++;
}
The first rotates up to far left corner 2nd bottom right corner.
onClipEvent (enterframe) {
_rotation-=2;
_x--;
_y--;
}
My quest is how would I get a 3rd + 4th box going opersite directions, Many thanks
Regards Barrie
Mouse Angle
Hi,
How do I track mouse's angle using trigonometry objects in
Flash 5? I need to find a way to convert any given x and y coordinates to degrees. (0 to 360)
Got any idea?
Thanks Much,
z27
Shooting At Any Angle
Hi,At the moment I have a movie clip that can move left right, up, and down, as well as rotate to any angle by keystroke. I was wondering though how
to write the code so it can shoot at any angle of rotation? At the moment the laser will follow the rotation of the movieclip, but will only go in the _x or
the _y coordinate, never both. Any ideas?
This is on the movieclip:
onClipEvent (keyDown) {
if (Key.getCode() == Key.RIGHT) {
_x = _x+2;
} else if (Key.getCode() == Key.LEFT) {
_x = _x-2;
} else if (Key.getCode() == 40) {
_y = _y+2;
} else if (Key.getCode() == 38) {
_y = _y-2;
} else if (Key.getCode() == 90) {
_rotation += -2;
_root.laser._rotation += -2;
} else if (Key.getCode() == 88) {
_rotation += 2;
_root.laser._rotation += 2;
} else if (Key.getCode() == 32) {
tank_x = getProperty("_root.tank", _x);
tank_y = getProperty("_root.tank", _y);
_root.laser.duplicateMovieClip("laser");
setProperty (_root.laser, _x, tank_x);
setProperty (_root.laser, _y, tank_y);
This is on the laser at the moment:
onClipEvent (load) {
laserMoveSpeed = 20;
this._x = _root.tank._x+60;
this._y = _root.tank._y;
}
onClipEvent (enterFrame) {
this._x += laserMoveSpeed;
if (this._x>600 or this._y<0) {
this.removeMovieClip();
Thanks,
Andy
Art-barn.com
Calculating An Angle
hi,
the math I was tought in highschool has left my brain along the years, so that's why now i have to ask this question here:
what is the correct syntax in actionscript for calculating the angle between two lines.
thanks in advance.
(The teachers told me I would need it some day, why didn't I believe them)
Checking Angle
i'm trying to figure out a way to to get the angle that the cursor is to a movie clip. if the movie clip was the center of a clock and the cursor was at 3 o'clock, it would be 90 degrees, 6 o'clock-180, and so on...
anybody have any ideas?
thanks
dougc
Angle Detection
this is a doddle, but I'm brain dead today.
all I want is some simple code to find the exact angle between the mouse and a movieclip. see I told you it was easy. nothing taxing here. Any ideas then?
cheers
Niall
Mouse Angle
I cant figure out. I need a simple mouse angle that says once the mouse is below 200(vertical) to tell target.
BTW thanks for all the help so far, this site is very cool.
Bubble MC From Different Angle
Please help. What am I missing?
I've decided to go different route with my bubbles. I have created a bubble via attachMovie method on level 4. Have called it "bubbleBottom".
Now I want to make it move and it's not going anywhere. I've tried a dozen different paths. Here is what I have latest:
function moveObject (mcName, number) {
name = eval(mcName);
speed = number;
moveSpeed = speed;
name._x += moveSpeed;
}
The call action on frame 1 is as follows:
moveObject("bubbleBottom",3);
When I debug, the variable level0.name=[movieclip:level0.bubbleBottom] shows in there and the moveSpeed=3.
Why am I having such a hard time passing the mc name when using attached movies on main timeline?
Please help.
Thanks MUCH in advance!
Gradient At An Angle?
I'm having trouble reproducing a gradient I made in illustrator. It is a linear gradient but it comes down at a 50degree angle. I can't seem to find any control that allows you to modify which direction a linear gradient is going in flash. Anybody have any tricks?
- Brian
the humble newbie
Determining An Angle.
I'm trying to find a tutorial or just the code if someone has it, showing how to determine the angle between two movie clips. For example, if I have two movie clips on my stage I want one of them to point towards the other. My trig is very rusty and I'm going crazy trying to find a good tutorial. Any help is appreciated.
Thank you.
The Mouse Angle
i would like to manipulate a frame inside a movie by a certian postion (x,y) on the stage. ive got stops on all frame,s inside the movie clip and i want to gotoandstop on certain ones depending on (lets say for this question )when the mouse rolls over an area between x400 and x500 can anyone help me? version 5 or mx
Help On Angle Formula
Im making a flash sorta 3d engine and I need a reliable angle formula (to get the angle with points X, Y, CX, CY)
Right now I'm using ACOS((X-CX)/Dis) where dis is the distance from X, Y to CX, CY. It seems that ACOS isnt all that reliable, and so I keep getting NaN. Does anyone know one thats fast and effective?
Angle From Coordinates
Hi,
whats a quick simple way of getting an angle (in radians) from an x,y coordinate?
thanks
phil.
Angle Move To X Y
i need to get a movieclip to move to a certain position when its roled over. i also need it to point to the position while its moving twards it. heres what i need.... onrollover change angle of mc and move to position. anybody got any ideas?
Height And Angle
how would i match the angle of a mc to the height of a mc like if its coming down then its facinf down and if its goin up hen its facing up, ect
Angle Input Box
How could i go about creating an input box which is rotated and slightly skewed. not perfectly horizontal
so when users type can type there name and it looks abit more funkier.
I hope you can do this, i tried putting in the input box into a movie clip and transforming it that way, but it didn't work.
Thanks for any help.
Dragging At An Angle
Hello again,
Need to drag an object fixed at a 45 degree angle. Any help would be appreciated. Thanks. Please also read my 'Obtaining Coordinates' post if you can help there too.
Mc Angle Detection
this script returns the angle of the mouse in a text box:
onClipEvent (mouseMove) {
x = this._xmouse;
y = this._ymouse*-1;
angle = Math.atan(y/x)/(Math.PI/180);
if (x<0) {
angle += 180;
}
if (x>=0 && y<0) {
angle += 360;
}
_root.angletext = angle;
updateAfterEvent();
}
Is there a similar script that will return the angle of a dynamically rotating mc that is constantly and randomly offset from the mouse angle, and post it in a text box.
Determing Angle
Hey all, somethin's been bugging me. In a pong game that I made, so that I didn't have a set angle for the ball, and rather it depended on how high or low on the paddle it hit, I wrote this code:
code: speedY = (ball._y - paddle1._y)/4;
speedX *= -1;
This way, the ball is always going at different angles. In the Pong game though, the angle of the paddle never changes, it is always at 180 degrees. In my newest game, the paddle's angle is determined by where your mouse is using this code:
code: function onEnterFrame() {
myRadians = Math.atan2(_ymouse-paddle._y, _xmouse-paddle._x);
myDegrees = Math.round((myRadians*180/Math.PI));
paddle._rotation = myDegrees+90;
}
Now I have a ball as well, and I want to make it work like it did in my Pong game - the difference is that now I can't just simply flip the X, because now the paddle's x and y coordinates, and its angle are constantly changing. I thought this would work:
code: speedX = (ball._x - _root.paddle._x)/4;
speedY = (ball._y - _root.paddle._y)/4;
But it always seems to be going in the same direction. I figured that was because of how my MC was set up (the x and y coordinates always stayed the same, only the angle changed). So I tried many things, but it still doesn't seem to be working.
I attached the FLA. The code for the ball is on the actual ball MC, and I added some notes...
Thanks in advance.
Shoot With Angle
good morning to all i am in serious trouble with a code i want a bullet to follow the angle of a cannon but no in straight direction but following the angle please help me
Angle Of Reflection
Hey everyone! Been a long time since I've been here, sheesh, maybe a few years.
Anyway, since my days of flash I've moved to PHP and Pool/billiards. Since this isn't possible in PHP, wondering if someone would either give me a direction, or is up to the challenge/job, depending on your level. What I'm looking for is a virtual pool table, used for calculating angles of reflection when making kick shots (cue ball to a rail, then to object ball). One rail kicks are easy, but when it comes to 2 and 3 rail kicks, the angles become difficult to read and predict.
Let me know if you have an interest in helping with this!
Steve
Bounce Off At Angle...
Hi guys...
I figure this one shouldnt be too hard.
What would be an ideal algorithm for having a ball bounce off a wall, when the rotation of the ball is given, and the direction that the wall is facing is given...
all i need is a script that takes the given direction of a ball, the given direction of the wall it has bounced off, and turns it into a new resulting direction for the ball...
looking at the directions i drew on the attached image, heres another example of some input and output.
ball_rotation = -25, wall_rotation = -180,
resulting_rotation = -155
ball_rotation = +45, wall_rotation = -135,
resulting_rotation = -135
(ie: ball simply reverses direction in this case)
ball_rotation = +135, wall_rotation = -90,
resulting_rotation = -135
does anyone know where I can get some good resources for this? or even make up a quick script demonstration?
also, if you're finding my explaination hard to follow, ill post an example in flash as soon as i can...
thanks guys
~theWaste
edit: image updated
HELP... Angle Of Arrow
can someone help me with the file attached please? i need to change the array to a 2-Dimensional Array.
thank you so much for u guys help...
and if it is not much of a trouble, can someone explain to me the meaning of each of the Math functions part. thankz again...
Getting Angle From Coordinates
is there a way i can calculate the angles between 2 points?
if i had the coordinates of my movieclip and the coordinates of my mouse pointer.. could i then find the angle between them?
how would i go about doing that?
thanks
Will
[F8] Rotating To Angle
I have an character on the screen. When I press right I want it to face right, down face down, etc.... but I don't want it to snap to this direction but rather rotate in the direction you hold.
code:
//Player Control
mWidth = Stage.width;
mHeight = Stage.height;
thisPlayer = this.attachMovie("thisPlayer", "thisPlayer", 0);
with (thisPlayer) {
_x = mWidth/2;
_y = mHeight/2;
}
thisPlayer.gotoangle = 0;
thisPlayer.onEnterFrame = function() {
if (Key.isDown(Key.UP)) {
this.gotoangle = 0;
}
if (Key.isDown(Key.DOWN)) {
this.gotoangle = 180;
}
if (Key.isDown(Key.LEFT)) {
this.gotoangle = -90;
}
if (Key.isDown(Key.RIGHT)) {
this.gotoangle = 90;
}
if (this._rotation>=gotoangle) {
this._rotation -= 1;
} else if (this._rotation>=gotoangle) {
this._rotation -= 1;
}
};
As of now my character is stuck in a counter-clockwise turning motion. Anyone know what to do?
Angle Of A Point
given that i know the x and y of a movieclip, and the x and y of a point, how can a calulate the angle from on the the next?
Motion By Angle?
Hello everyone,
I am having a problem in trying to come up with a code to get a movie clip (in the center of the stage with an instance name of "mTarget") and another movie clip (instance named "mEnemy").
The purpose of the mEnemy is to appear from a random bearing (0-360 deg from the mTarget) more or less like a missile fired from an aircraft and come right at the mTarget and after passing the mTarget (about 50pixels) make the mEnemy disappear (this can be done with the removeEventListener) but the randomized location of the mEnemy and to take on an angle motion (in relation to the mTarget) directly at the mTarget is what's killing me.
I have tried different codes I have searched in here and from books but they don't really show on how to calculate the distance between them and use that to create the angle in which the mEnemy needs to take to come right at it. So, instead of posting some non-sense code that I don't even have a clue, I rather leave it to the experts to teach me the right way.
(new to AS3 but rapidly learning.....well, except for this one headache)
Any help would be appreciated!
[F8]Angle Changes Frame
I have an example here. I need to make a certain angle like 180, go to the 3rd frame. The following angles.
When the mouse is at one of these angles, it changes frames.
0 Degrees frame 2
90 Degrees frame 3
180 Degrees frame 4
270 Degrees frame 5.
Pre-Made Example, but not complete.
http://spamtheweb.com/ul/upload/3808..._move_test.php
Script used in frame 1.
Code:
bug_mc.onEnterFrame = function() {
var dx = _xmouse-this._x;
var dy = _ymouse-this._y;
var angle = Math.atan2(dy, dx);
this._rotation = angle*180/Math.PI;
};
Shoot At Angle
My current project is a turret game. The kind where you have a turret in the middle of the screen, and you use the mouse to control it and shoot.
Rotating the turret isn't too bad, but how would I get it to, shoot something?
I tried just putting it in the turret MC, and when you click, the shot moves, but then it curves if you move the mouse.
So how would I do this?
Get X And Y From Angle And Radius
I need to be able to get x and y positions from angle of a dot (moved by mouse) from another dot (stationary,at center of stage), and the radius, being the distance also from the center dot to the outer dot.
I don't need the code to make the dot move or anything, i just want to know if anyone has the code/formula to get an x/y position from radius and angle.
Thanks in advance,
Sunlis
Angle Problem
Dear Guys,
I have a problem with the below project. The following are the requirements for the project & the attached file is where I have come till now. Iam just not able to crack the issue. Can one you please help.
Interior & Exterior of the marked angle:
1. A point "D" is marked on one line & point "F" is marked on another line.
2. The two lines are joined at one point "E" forming an angle DEF, the angle will be repesented in the form of an arc (green colour) and the end of the lines are shown with pointed arrows.
3. The points D & F remain fixed on the line and cannot be moved to any other position on the line but the lines can be moved in a circle to any angle.
4. The measure of each angle (eg: 47 degree) will be written on the right side of the arc.
5. The region covered in the arc on the positive angle side to be in blue colour & called the "interior region".
6. The angle formed opposite the covered region to be called the "exterior region" will be in red colour.
7. As the point "D" & "F" is dragged to different position, the angle changes and the corresponding colours in both the region also change.
8. When the line with point "D" is moved on the anti clockwise direction & meets the point "F" the angle will be 360 degrees with full blue colour as there is no exterior region.
9. When the line at point "F" is dragged on the clock wise direction to meet "D" then the angle will be zero degrees and the entire region will be in red colour and the label appears as "Exterior region". There will be no Interior region shown.
General guidelines:
1. Show all the points, lines, arc, more thick & dark.
2. The inner area of the arc will always have a common colour.
3. The line should be shown with arrow marks at the end.
User Instructions:
Drag the point "D" or "F". DEF is the interior of the angle and the area outside is the exterior of the angle.
Regards,
Rajesh
Angle Movement
I have 5 cubes that just have a random oscillating movement but I want an attraction to the mouse if the user is within a certain pixel range. When it attracts to the mouse it should stop when the mouse is over the cube then go back to its original position and start osculating again when the user is off the cube. Only one cube at a time should be attracted to the mouse.
It kind of does what I want now. The osculation is correct but it should have some kind of force to the mouse and then stop. When the user is off the cube it should move back and osculate smoothly, right now it moves back and jumps into osculation mode.
ActionScript Code:
class com.cube.MoveRan extends MovieClip {
private var vx:Number;
private var vy:Number;
private var angle:Number=0;
private var maxDistance:Number = 40;
private var ranX:Number;
private var ranY:Number;
private var origX:Number;
private var origY:Number;
function MoveRan() {
init();
}
private function init():Void {
_global.mouseAttract=true;
vx=_x;
vy=_y;
ranX=Math.round(Math.random()*5+5);
ranY=Math.round(Math.random()*2+1);
angle=Math.round(Math.random()*1-1);
origX=_x;
origY=_y;
attachEvent();
}
public function move():Void {
_x =vx+ Math.cos(angle)*ranX;
_y=vy+ Math.sin(angle)*ranY;
angle+=.1;
if(_global.mouseAttract){
moveTowardsMouse();
}
}
private function attachEvent():Void{
onRollOver=function(){
swapDepths(this._parent.getNextHighestDepth()-1);
_global.mouseAttract=false;
};
onRollOut=function(){
_global.mouseAttract=true;
delete this.onEnterFrame;
this.onEnterFrame=moveBackToOrig;
};
}
private function moveTowardsMouse():Void{
var mouseDistance:Number = getMouseDistance();
if (mouseDistance<maxDistance) {
delete this.onEnterFrame;
this.onEnterFrame=easeToMouse;
}
}
private function easeToMouse():Void{
var tx=this._parent._xmouse;
var ty=this._parent._ymouse;
this._x+=(tx-this._x)/6;
this._y+=(ty-this._y)/6;
if(Math.abs(tx-this._x)<0.6 && Math.abs(ty-this._y)<0.6){
delete this.onEnterFrame;
}
}
private function moveBackToOrig():Void{
this._x+=(origX-this._x)/6;
this._y+=(origY-this._y)/6;
if(Math.abs(origX-this._x)<0.6 && Math.abs(origY-this._y)<0.6){
delete this.onEnterFrame;
this.onEnterFrame=move;
}
}
private function getMouseDistance():Number {
return (Math.sqrt(this._xmouse*this._xmouse+this._ymouse*this._ymouse));
}
}
Angle Movement?
hello, i have a problem on actionscript and i am wondering if anyone knows how to solve it
the problem is,
i have a movie clip that moves up of down when i press the up and down keys. it also rotates when i press the left and right keys. but whenever i want to rotate it and then move it it will still move forwards and backwards and i want it to go in the direction that its facing does anyone know how to solve this
the actionscript i am currently using is as follows
Quote:
on(keyPress "<up>"){
_root.veh1_mc._y -=3
}
on(keyPress "<down>"){
_root.veh1_mc._y +=3
}
on(keyPress "<left>"){
_root.veh1_mc._rotation -=3
}
on(keyPress "<right>"){
_root.veh1_mc._rotation +=3
}
Angle Question
Ok I'm pulling my hair out over this. I'm very bad at complaining things so just let me know if I need to clear anything up or rephrase anything so it makes more sense.
Ok so picture a circle. Now picture that I have 2 numbers that are degrees which are points on the circle. How would I determine which way to rotate 1 point to the other point.
For example. Lets say I have 1 point at 180 degrees. and another point at 90 degrees. Knowing these two numbers I can say that the quickest way for the first point to meet the second point is for it to rotate around the circle counter clockwise. But what if I didnt know the numbers? How would this be determined?
Angle Of Elevation
hello everybody
currently i am working in a project where we have to calculate angle of elevation where height of object is static but distance is variable.i had calculated the angle but there is a problem in finding the distance can anybody help me out of this For this i am attaching the file with it
Angle + Spread
How it have it right now
it starts off at a -90 angle...now I want to to spread 180 from that point.
Problem is takes it as a circle and does -90 to 90.
What I need to to do is
it is at -90 angle then go half of 180 + the set angle vice verse.
any idea how to achieve this?
Shooting With Angle
good morning to all i am in serious trouble with a code i want a bullet to follow the angle of a cannon but no in straight direction but following the angle please help me
HELP Slider On An Angle
I need to create a slider that runs on about a 30 degree angle to move across a picture i've been supplied. I can create everything about the slider, even make it move horizontally or vertically [only] but don't seem to be able to make it run along a particular line that's on an angle... do i use a motion guide or what?
If that isn't clear, I basically need to have an object moveable from one point to another that is not directly above/below/beside it. Possible?
Help would be much appreciated. Thanks in advance!
Shoot With Angle
can anyone help me with the code i want to shoot a bullet for example but the bullet will follow the angle of the gun
Shooting With Angle
good morning to all i am in serious trouble with a code i want a bullet to follow the angle of a cannon but no in straight direction but following the angle please help me
What Is Mouse Angle?
I've been hearing this asked for in MANY posts, but I don't even know what it is?
Shooting With Angle
Ive got the whole gon shooting thing down for a game now all I need it to do is have it shooting at an angle. My shooting script is the basic duplicate movie clip if moviecllip x or y is greater than stage width or stage height delete clip. Thats the basic code I got. Now I need to shoot my bullet at an angle. Like say a missel that goes up and then drops down the height and distance depending on how far you rotate your cannon .
Angle W/ Trig
I have a game that I'm making, and regardless of other stuff, I need to make essentially a turret. I know how to code where it should move towards (that's easy), and I know somewhat how to use math stuff on flash. But when I tried to implement it on this, it doesn't work. See code:
angleA = Math.atan2(TARGET._y-HERO._y, TARGET._x-HERO._x);
var degrees = angleA/(Math.PI/360);
BULLET._rotation = degrees;
It is correctly placed, don't worry about that.
Bouncing At An Angle
Ive been messing around with gravity and ive gotten the ball to fall and bounce off these blocks that i made. The blows are angled however, how do i get it to bounce in the direction of teh angled blocks?
|