ActionScript 2.0 :: Calculate The Direction And Speed A Circle Has After Colliding With A Static (non-moving) Circle?

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


Similar Posts:


ActionScript 2.0 :: Calculate Direction And Speed Circle Has After Colliding With A Static Circle?

Mar 8, 2005

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.

View 6 Replies

ActionScript 2.0 :: Calculate The Circle Radians?

Feb 20, 2010

i have one problem. i create one circle and i placed more than one points outer of circle (the points are created dynamic).

View 1 Replies

ActionScript 3.0 :: Scrolling Circle In Direction Of The Mouse?

May 13, 2011

so basically I have a circle which I got to spin around and stop when the mouse is over it. However I now need it to also spin Anti-Clockwise if the mouse is near the top of the page and clockwise if the mouse is at the bottom of the page.

Can anyone help? I did the animation through tweening in flash so my code is tiny, but here's what it is. I'm new to flash so forgive me if I don't know what I'm doing.

[Code]...

View 6 Replies

ActionScript 2.0 :: .rotate Circle With Buttons, Change Direction?

Oct 20, 2010

what i have is a circle image (for this purpose lets say it looks like a clock). For example: when you click 3 o'clock, the whole clock needs to rotate around with the 3 o'clock btn at the 6 o'clock position (with the pivot point in the centre). each of the 'time' positions (2 o'clock, 3 o'clock, 4 o'clock ...etc) needs to be a button and thus be able to rotate around to the 6 o'clock position.This would seem simple enough by just using a.rotate value or using tween movieclips...however the tricky part is:the actionscript needs to determine which way the clock turns (anti/clockwise), dependant on where the clicked time-btn's position is. it needs to be some sort of if statement that says:if (3'oclock-btn) is positioned between 0 degrees (being original 12'oclock position) and 180 degrees (original 6 o'clock position), then rotate clockwise to the 6 o'clock position. If the (3o'clock btn) is positioned between 180degrees and 259 degrees (12 o'clock position), rotate anti-clockwise to the 6'oclock position.

View 5 Replies

ActionScript 3.0 :: Make A Circle Turn And Move In The Direction?

Oct 15, 2010

what i am trying to do is make a circle turn and act like a wheel... what code would i use to make a circle turn and move in the direction it is turning while on the ground?

View 12 Replies

ActionScript 2.0 :: Make One Circle Follow The Mouse Cursor Inside Another Circle

Sep 30, 2005

i want to make one circle follow the mouse cursor, inside another circle. Similar to an eye looking at the cursor. Ive attached an example.

View 4 Replies

ActionScript 2.0 :: If Statement / Variable - Say If Circle Shows Up Change It To Circle (french)

Nov 5, 2008

I have text in a dynamic field showing up as circle. I want to say if circle shows up change it to cercle (french).

[Code]...

View 1 Replies

ActionScript 3.0 :: Graphics - Paint (change Color) Inside Of Circle When A User Draw A Circle

Aug 24, 2009

I`m working on a app that you can draw lines.....like circles, rectangles... my problem is when a user draw a circle for example....i wanna be able to paint (change color) inside of this circle. I`ve tried working on Shapes with cacheAsBitmap = true and Bitmaps with BitmapData but it doesn`t seens to work.

View 4 Replies

Actionscript 3 :: Change Shape Of Circle By Dragging Point On Circle

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

ActionScript 2.0 :: Drawing A Circle - Circle Diameter Has To Be Controlled By A Button

Oct 6, 2009

I have to draw a circle using action script. The Circle Diameter has to be controlled by a button.

View 0 Replies

ActionScript 3.0 :: Circle Circle Frame Independant Collision Reaction?

Apr 10, 2010

Trying to do circle circle collisions via math which I'm really having trouble with. One circle (player) just moves from keyboard. The ball reacts to the player. All the code shown is in my players class and I passed in a reference to the ball.

On my enterframe I have:

Code:
var xmov1 = xSpeed;
var ymov1 = ySpeed;
var xmov2 = ballRef.xSpeed;
var ymov2 = ballRef.ySpeed;

[code]....

Perhaps I'll go with a box2d equivalent instead of trying out my own physics shenanigans.

View 2 Replies

ActionScript 2.0 :: Start Drawing First Circle And When First Circle Is On Half Way?

Sep 19, 2004

Here I what i need is : Start drawing first circle and when first circle is on half way, Start second circle.same way second and third circles. and after completing 3 circles, just gotoAndPlay 2nd Frame .

View 3 Replies

Professional :: Circle No Longer A Circle On Publish?

Feb 18, 2010

I have a simple three ring animation where the three rings fade in and out.On the stage the rings are a perfect circle, in the publish preview they look fine, but once I publish the SWF, all of the sudden the rings are not perfectly round anymore.
 
They are almost perfect but right at the top and bottom there is just a small portion which has sort of "flattened out"...

View 2 Replies

Professional :: Create A Circle With The Circle Tool?

Apr 26, 2011

I bought a Flash video tutorial online for Animating and the FIRST step is to create a circle with the circle tool, and the guy does it online, and it fills itself in. I repeat his actions exactly and I cannot get the same result at all. I just get a circle.

View 5 Replies

ActionScript 2.0 :: Moveable Circle Around Another Circle - No Overlap

Apr 5, 2007

I have two MC's, circular in shape. One of the circles is stationary and you can drag the other. I'm trying to get the moveable circle to be able to move around the circumference of the stationary circle, but not overlap. I'm able to detect when they overlap, not using hittest. I just can't figure out how to code it so that the draggable circle can't be moved over the stationary circle.

View 4 Replies

ActionScript 3.0 :: Circle-circle Collision With Rotation?

Jul 5, 2010

Does anyone know of any tutorial or code example that deals with resolving circle-circle collisions including rotation?

View 2 Replies

ActionScript 3.0 :: Constrain Circle In A Circle On Startdrag?

Jan 6, 2012

I have been trying to get this right for hours now it cant be as hard as I am finding it! but basically I have a circle and in that circle is a circle and all I want is for the inner circle to not be able to leave its parent. that's it but I just cant get it to work.

View 1 Replies

ActionScript 3.0 :: Circle Is Not Moving Smoothly?

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

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

ActionScript 3.0 :: Moving A Line In A Circle?

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

IDE :: Number Of Images Moving Around Circle

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

ActionScript 3.0 :: Keep A Moving Object Inside A Circle?

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

Flash CS5 - Moving Object Around In Circle One Degree At A Time

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

ActionScript 2.0 :: Circle Stop Moving At Obstacle (Square)

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

ActionScript 2.0 :: Circle MovieClips Moving Around Randomly On Stage

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

ActionScript 3.0 :: Collisions Between Moving Circle And Rectangle Object

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

ActionScript 3.0 :: Make A Circle Slide ( Slider That On The Shape Of Circle Instead Of Vertical And Horizontal Slider)?

Jul 3, 2009

I'd like to make a circle slide ( Slider that on the shape of circle instead of vertical and horizontal Slider) like this one:

[URL]

Is there a ready Component on the web.

View 0 Replies

ActionScript 2.0 :: Dynamically Moving An Object Along A Circle Motion Guide

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

ActionScript 2.0 :: Moving Circle To X Position When User Click On Square

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







Copyrights 2005-15 www.BigResource.com, All rights reserved