Flash :: Moving A Circle Around A Point?
Aug 20, 2011
I have a circle (bounding circle) offset from the centre point of my entity and I'm looking on how to move that circle around the entity as it rotates so that it's always in the same spot of the character.For example,say I have a bounding circle for the front of a car, when the car turns, that bounding circle needs to turn to So I have two points: position which is the position of the entity's centre point and offset which is the offset of the circle from that position. This assumes an angle of 0.
So if my car is facing 0 degrees: position (150, 150) and offset (50, 0) then the bounding circle would be at 200, 150.Now if I rotated the car 90 degrees, the bounding circle should be at position 150, 200.This is what I have now:
var differenceX : Number = _centre.x - _offset.x;
var differenceY : Number = _centre.y - _offset.y;
var rotatedX : Number = differenceX * Math.cos(_angle);[code]........But it's giving me these long ovals and now a perfect circle.
View 3 Replies
Similar Posts:
Mar 16, 2012
I want to create circle, and put 8 points on it. So, user can drag each point in order to change it's shape.
Is there any way to do this in flash?
I have some following code:
Ref. - How to draw a continuous curved line from 3 given points at a time
package{import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.geom.Point;
[Code].....
So, can anyone convert these three point curve line to 8 points circle?
View 1 Replies
Mar 8, 2005
I'm developing a game atm, and I need some help on the mathematics/coding of colliding circles (and their change in x/y speed). What i need to know is how to calculate the direction and speed a circle has after colliding with a static (non-moving) circle. I know how to detect a collision between the two, but I'm not sure about the maths I need to give the circle the right speed and direction after the collision
If i do know how far away the two circle-points (in the middle of each) are to each other (in both x and y coords) would it be easy for me to find the new speed and direction of the large circle in the example above? I know that I somehow should use the angles to pretend the circle hits a flat "wall" (as it only hits one point), and then calculate the new speed/direction. My only problem is that I'm not sure how to decide the angle of this flat "wall" and how x and y speeds should change when colliding with a wall that is angled. Does anyone here have any insight, links or tips on how I can du this?
View 6 Replies
May 3, 2006
How can I move a point (or circle) slowly and the point let behind a line.When the point turn back the line will be erase.
View 8 Replies
Aug 2, 2011
I have an object called point that I can move around the screen with my mouse. This object has a vector mapped through it (_v1) using the center of the stage and "point"s x,y location in order to draw the vector (note all of this is working fine). My problem is occurring when I set up was a button that simply sets a value to true if you press it. The idea behind this button is that when pressed, whatever location "point" is at, it will move 1 degree clockwise in a circle around the center of the stage (this is all happening in the frameHandler so I can keep clicking the button to make it continue around the stage).
The code I am using is based in an if statement listed below:
if(clockwisePressed) {
var v1angle:Number = _v1.angle;
v1angle++; //increase the angle by 1 degree
if(v1angle>180) {
v1angle -= 360; }
[Code] .....
So what is happening here is that clockwisePressed has been set to true so this fires off. My vector (_v1) is set up to tell me the angle (already converted from radians to degrees) but it's a read-only value. So I assign it (_v1.angle) to v1angle so I can mess with it and increase it by 1 so I'm moving clockwise around the center of the stage. Then I just check to make sure that it falls into a range between -180 and 180 (if I trace _v1.angle around the stage, 0 degrees is to the left, 90 degrees is straight up, 180 degrees is to the right, and -90 is straight down). Now using the formula I derived from this thread but converted to work with 0 degrees pointing to the left and the value for Y going up the further down the stage you go, I came up with
x = centerX - radius * cos(angle)
y = centerY - radius * sin(angle)
Now when I make a sample chart on paper and use these values on my calculator, this works like a charm. If I plug in an angle, the radius, and center I get a point right on my circle I draw on a sheet of graph paper. However, when I actually try this in flash, the "point" jumps all over the stage. (Note that _v1.m is just the magnitude of the vector between the center of the stage and "point" which is the same as the radius). So I trace everything and the values for cos and sin don't seem to be coming out right. For example, if my angle is -1.9581 and I take the cos of that on my calculator I get something along the lines of 0.9994 but flash traces Math.cos(angle) to be -0.3777. Isn't using Math.cos(-1.9581) the same as putting -1.9581 into your calculator and hitting cos?
Below is the corrected code that works:
if(clockwisePressed) {
var v1RadAngle:Number = Math.atan2(_v1.vy, _v1.vx); //get angle in radians
v1RadAngle += 0.0174; //increase the angle by ~1 degree more or less
//Now just move the crosshair and get it ready to be redrawn
point.x = centerX - _v1.m * Math.cos(v1RadAngle); //_v1.m = radius
point.y = centerY - _v1.m * Math.sin(v1RadAngle);
clockwisePressed = false; //remove button pressed boolean
}
View 1 Replies
Jul 15, 2011
i have the follow issue :
I have a point which is setted at the border on a component, with changed transform point to the center of a component in order to match the component rotation.
the important part is when i try to get the point XY after rotation - they remains the same as before rotation.
how to get XY, after rotation ( changeing point.rotation property to specific degrees of rotaion )
View 2 Replies
Feb 19, 2005
I know some basic trig. but how do i find an angle from an anchor point and a moving point?
adjecent = _root.anchor._x-_root._xmouse;
opposite = _root.anchor._y-_root._ymouse;
hypotenuse = ((adjacent ^ 2)+(opposite ^ 2)) ^ 0.5;
View 2 Replies
Apr 15, 2011
This should be a bit of simple geometry: How do I calculate the points to draw the lines in the code below so that it makes a 2D cone or wedge shape?
import flash.geom.Point;
//draw circle
var mc=new Sprite()[code]...........
UPDATE:I should have mentioned my aim is not to draw a wedge shape, but to draw a line from a random point to the edge of an existing circle.If you're more comfortable with algebra than actionscript,
View 5 Replies
Feb 4, 2009
how can me move point arrount circle
just i want the point that you press on it and move it arrount the circle
View 0 Replies
May 17, 2011
I want to add point to curve when i click on the curve ,make sure the Original point not change ,eg. a Original point is a control point after add it is Still a control point ,so,may be it is need add two point at the same time
View 3 Replies
Jan 1, 2011
I am trying to get a circle to move across from one horizontal point to another. I want this to circle to repeat itself after a certain amount of time but for the previous circle to carry on moving. I also want the circle to appear at different vertical points.
[Code]..
View 1 Replies
Mar 6, 2009
What I'm trying to do is make a dial-type of interface, where you click on a point on the edge of a circle and that point will rotate to another point at the top of the circle. What I can't figure out is how the make "Point B" rotate to "Point A", where "Point A" is always fixed at the top of the circle and "Point B" (and Point C and Point D, etc...) are located along different points on the edge of the circle. I'm using the tween function to rotate, so what I need to figure out is how to get the difference in the rotation between the two points.
View 7 Replies
Mar 9, 2009
I am trying to rotate some points around the center of the circle(0,0), however I'm getting weird values from the output. I've commented the problem code..
Code:
var r:Number = 10;//radius
var y:Number;
var x:Number;
var a:Number = 90;//angle of which the semi-circle is facing.. could be a random angle.
var ax:Number;//rotated points
[Code] .....
I am using the semicircle in BitmapData collision checking with getPixel(), with a moving circle...
View 1 Replies
Jun 1, 2011
I am trying to animate the circle to follow the cursor point. Its working fine, but when you move the cursor little faster the animation struck.
import flash.events.MouseEvent;import fl.transitions.Tween;import fl.transitions.*;import fl.transitions.easing.*;
var moveXY:Number;var speed:Number = 1;
[Code].....
View 8 Replies
Mar 2, 2011
I am trying to move a line around in a circle, around a fixed point (not 0,0). As in the way a clock hand moves around with one end at the middle and the other end traveling in a circle. I tried the rotation function but that moves the entire object around (0,0), I need the point in the middle stationary and at a non (0,0) point.
View 9 Replies
Feb 28, 2010
Recently I came across a site showing a no. of images (probably 8 - 10) rotating around an invisible eclipse. When we put mouse-pointer over any of the images it's tip shows a linked site's name and if clicked that particular site opens up. Only one image is displayed perfectly which is on the top while rotating, while other remain blurred out not clickable. How to create such effect as I need to get it implemented.
View 1 Replies
May 5, 2011
It's the beginning of a Monkey Island / Grisworld The Goblin kind of ultra short and simple game. Actually this is the only think I have to figure out.
Actually it already works if you click the x where it's positioned on the screenshot, but it doesn't work other places. And yes I've tried everything, and I'm just nok smart enough to figure this out.
More precisely it's the alternative path, after the arrow collides with the circle, that's causing me problems - since it's going to find it's way to the point clicked on stage.
View 1 Replies
Dec 23, 2010
I have two circles, an inner circle and an outter circle. I'm trying to find points that reside within the area between the edge of the inner circle and the edge of the outer circle.
View 1 Replies
Dec 6, 2009
How to find out different circle's center point of a bitmap?
just like photo above, how can i locate the 2 center points of circles?
i only know using .getColorBoundsRect to get a point, but this only apply to one circle, in fact i wanna get different points according to the bitmap.
View 1 Replies
Mar 25, 2007
How to make a point rotate about the circumference of a circle upon dragging. How do I go about doing it? Is there something to do with the
startDrag(...); ?
From what I have right now, I can move the point but not on the circumference of the circle.
View 3 Replies
Apr 24, 2010
I have a circle drawn on the screen, wherein I add a moving object. I want it to keep inside. My strategy is to calculate the circle's radius and compare it with the distance the moving object is off its center. I beleive it's the proper solution. However, I'm having a problem with letting Flash know when the running guy should stop, so he doesn't leave the circle and ruin all the fun. Here's the code I'm using (it's not working of course):
function moveTheCreaturesRightwards(event:Event)
{
if(maleMovingRight == true)
{
[Code]....
The line: rayMale.width = maleRadius.width; was added when nothing else had seemed to be working
View 3 Replies
Feb 17, 2011
I posted a while back looking for a function to make one movieClip circle around a fixed point. The solution I was given (which has worked perfectly up until now) is:[code]This function is called repeatedly by a Timer (loopTimer) with delay 10.The problem I have hit now though, is that if I want to modify or reverse the speed of rotation at any point it causes a jump in position (because I am setting the x and y values directly, rather than incrementing them e.g. "x = ..." rather than "x += ..."). Can anyone see a way to modify this function so that I can just increment the x/y positions?
View 5 Replies
Jul 10, 2009
I have a circle and a big square. The circle can be moved using the keyboard. I want the square to act as an obstacle, so the circle cannot be moved into it and the circle stops when it hits it, just like a if i were to try to walk into a building. Is there an easy way to do this?
View 7 Replies
Aug 6, 2005
I want the final result to be a stage with a certain number of circle MC's moving around. I have made the circle MC, and added the AS so that it will start at a random point with a random color, then start moving around randomly. I want to make it so that In the beginning the document will duplicate the movie clip x amount of times, using a for loop. I want to then have all the new circles move around, and when two circles hit each other, they will dissappear, using the removeclip function. You can only use this on duplicated movieclips though, so how would i make all the circles duplicated? Is there a way to duplicate the original movieclip x amount of times then delete it? Or is there a way to remove the original after it is in a collision? Also I don't know how to do the collision detection. I am thinking of using a hittest, but would I just do it with a for loop? Is there a way so that if an MC hits any other MC?
View 3 Replies
Oct 9, 2010
In AS3 is there an easy way for collisions to take place between a moving circle and a rectangle object. A moving circle has a direction and you need to know how it collides with an object rather than knowing it just hits. In .net you use a points test where you test several points around a circle to see what hits an object and then you can work out what direction it will bounce off.
View 2 Replies
May 20, 2010
I'm drawing a 3D pie chart that is calculated with in 3D vectors, projected to 2D vectors and then drawn on a Graphics object. I want to calculate the most left and right point of the circle after projected in 2d. (So not 0 and 1 Pi!) The method to create a vector, draw and project to a 2d vector are below. Anyone knows the answer?
[Code]...
View 1 Replies
Dec 28, 2010
We have a flex app that will typically run for long periods of time (could be days or weeks). When I came in this morning I noticed that the app had stopped running and a white exclamation point in a gray circle was in the center of the app. I found a post about it on the Adobe forums, but no one seems to know exactly what the symbol means so I thought I'd reach out to the SO community.[URL]..
View 3 Replies
Jul 5, 2005
I'm trying to move an object along circlular motion guide dynamically using two buttons -- a left button, when pressed down, will move the object counter clockwise, and the right button clockwise.
View 2 Replies
Jun 18, 2008
I have a circle and a square on the stage. When you click on the square the circle will go to "circle._x = 300" when the circle is at 300 I want to make it when you click on the square the circle will go "circle._x = 45"
Code:
moveCircle = function () {
circle._x = 300;
if (circle._x >= 300) {
circle._x = 45;
}} square.onRelease = function() {
moveCircle();
trace(circle._x + "is the position of the circle");
}
View 5 Replies
May 11, 2009
I want to make an editor like this site. [URL] If you browse this link you will find "Button. If you press this button you will navigate to a editor to design your layout. After draw a rectangle or circle or line you can resize that or can rotate that. When you finish if press the "you will back to the previous page where your desinged layout display. If you press the "" again then you will navigate the editor with the previously designed layout. I want to make a site like this. I want to use the flash cs4 to make the editor. Anybody knows how to draw a rectangle or circle shape with mouse and how to scale by setting the point and how to rotate by setting the rotation point also by using flash cs4 and as3?.
View 3 Replies