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


Similar Posts:


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

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

ActionScript 2.0 :: The Square And The Circle Both Move?

Jul 27, 2003

I have a square that is a button symbol. There is a cirlce that is a movie clip symbol. I assigned the following actions to the button

on (keyPress "Left") {
currentX = this._x;
this._x = currentX - 2;[code].........

For some reason, the square and the circle both move. how can i just make the block move and not the circle.

note: the <> symbols are not put surroundin the key names

View 1 Replies

ActionScript 3.0 :: When A Circle Hits A Square

Oct 15, 2009

i would like to know when a circle hits a square.Following code returns true when the rectangle of the MovieClip (blue) hits the square and not the circle itself:

circle.hitTestObject(square);

In as2 you had an extra parameter to indicate that.

View 3 Replies

ActionScript 2.0 :: Square 1 + Triangle 1 + Circle 1 = Movie 1 ?

Jan 30, 2009

I want to build a specifik thing in flash, and don't really know where to start.... Say I have:

3 images of 3 three different squares

3 images of 3 three different triangles

3 images of 3 three different circles

The first thing you see is Square 1, Triangle 1 and Circle 1. If you were to click on Choose Square, Square 2 will appare in Square 1s place. If you click on it one more time, Square 3 will appare, and then round again to Square 1. Same thing for all the shapes.When you're satisfied with your selection of shapes you click OK and then you get to see a movie, based on whatever choices you've made. Because there are 3 different shapes and 3 different objects within each category, there will be 9 different movies to watch (3x3=9).One example of how this could turn out is:

Square 1 + Triangle 1 + Circle 1 = Movie 1

Another one could be

Square 2 + Triangle 2 + Circle 2 = Movie 6

View 10 Replies

ActionScript 3.0 :: Square Object In The Middle Of Circle?

May 28, 2010

I have a square object in the middle of circle.and i can move square object using up, down, left, riht arrow keys. I need script for when square object touches circle, then it goes to back, I have use for this below code :

var myobjdim:Array=new Array;[code].....

In above code "myobjdim" is square object and "bg1" is circle object..

View 1 Replies

ActionScript 2.0 :: Draw A Square/circle/anything One Pixel At A Time?

Jul 27, 2005

how to draw a square/circle/anything one pixel at a time, using Actionscript instead of tweens?

View 1 Replies

ActionScript 2.0 :: Motion Method - Take A Circle And Place It In The Center Of A Square Scene

Aug 15, 2003

-Take a circle and place it in the center of a square scene.

-Make a rectangle and snap its left edge to the circle's center.

-Make another rectangle and snap its left edge to the right edge of the first rectangle.

How would you make it so movement doesn't happen at the registration point but on the whole arm. Say i ran a rotation script on the upper arm with +=1 and the lower arm with +=2. How would you place the parts, what format would they be converted to and what would the script format be. Multiple methods would be welcome of course!

View 1 Replies

ActionScript 3.0 :: Making Beat Em Up - Character Stop Moving If The Attack Is Pressed And Once It Is Released Start Moving Again?

Nov 2, 2010

im currently making an "AS3 beat em up" ala streets of rage or double dragon.Currently i have my character moving and a few animations done and i am trying to figure out how to make attacks work.I have some "basic" animation for his attack, but im not sure how to get it to work correctley.What happens is, if you press control (the attack button) whilst the character is walking he just keeps moving and is stopped on the attack frame.I want the character to stop moving if the attack is pressed and once it is released start moving again.

hero.gotoAndStop('still');
var left:Boolean = false;
var right:Boolean = false;[code].......

View 2 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 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 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 3 :: Box To Circle Collision - Continue Moving And Never Collide When Swapping Values Around

Feb 24, 2012

I'm trying to implement a aabb to circle collision.

[Code]...

Somehow the collision does work as expected. Either they never move at all and "collided" was traced, or they'll continue moving and never collide when I tried swapping values around. Is there something i'm missing in my logic??? My box-box and circle-circle collision are working fine.

View 2 Replies

ActionScript 2.0 :: How To Create An Obstacle

Oct 28, 2005

I am creating this game and I have created this rectangle shape (the wall). I want an object to stop moving when it touches the shape

View 2 Replies

ActionScript 2.0 :: Mc Will Smoothly Stop When Stop Moving The Mouse

Aug 1, 2004

I have a MC that follows the mouse. I want to do so the MC will smoothly/softly stop when i stop moving the mouse. Is it hard to code, And it would be very nice if someone could do some code for it

View 2 Replies

ActionScript 2.0 :: When Creating A Dynamic Square With The Api - Won't Drawing Api Square Object

Dec 2, 2010

when creating a dynamic square with the api. 400 by 400. I am not sure why it wont draw the object

[Code]...

View 2 Replies

ActionScript 2.0 :: Have An Enemy Square That Chases The Player Square?

Jan 15, 2010

I have this game, and some levels have a moving square as the player, you move the square with your arrow keys.... I want to have an enemy square that chases the player square.... They only chased mario when you didn't look at them? Kinda like that...... but in this regards:

I only want the enemy square to chase the player square when the player square moves.... soo say the player square moves 5 pixels per movement (know how to do all that), I want the enemy square to move when the player square moves..... towards the player square at like 7 pixels per movement..... so eventually you won't be able to avoid the enemy square....

View 4 Replies

Flash :: Stop The Loading Circle In Browsers?

Oct 3, 2011

Imagine I have a flash mp3 player and when the page loads the player starts to play a song. So while flash is downloading the mp3 file the browser reports the page like it's still loading. Which I understand, there are still active downloads. But a client wants me to somehow tell the browser not to show this progress (like the circle in chrome) for the files the player downloads.

View 1 Replies

ActionScript 3.0 :: Stop Moving MC - Fish To Stop Swimming After Clicked It And Start Swimming After Another Click

Jan 1, 2012

what wrong with the functin 'stopFish' Without this function the fish in the tank swims but when I add it, it doesnt anymore. I just want the fish to stop swimming after I clicked it and start swimming after another click.

View 1 Replies

Stop Moving At Specific X Coordinates?

Nov 19, 2009

Im going to attatch the fla on here...I am also going to give you the script viewable here...im completely a beginner so i made my self notes
also this is not all my coding im just learning off of it to create my own project... What coding would i use to tell the mc to stop scrolling once it reaches a certain x coordinate? for example x=0 (left side of stage) or x= -484 which is when right side of picture is at right side of stage... and can i setup math for it to automatically determine the correct x coordinate (based off mc width) to stop at?? if there is easier scripting to do the same....fill me in
 
oh and x is off of the stage typically...this is panoramic pics im scrolling

[Code].....

View 2 Replies

ActionScript 1/2 :: HitTest Trying To Stop Something Moving?

Jun 13, 2010

ok here is the scene

_root.playa
_root.playa.feetMC
_root.corneria
_root.corneria.limitsMC

[Code]...

View 3 Replies

ActionScript 3.0 :: Object Won't Stop Moving

May 11, 2010

I have this code where I want edge_btn to move to the left side of the stage, but I can't figure out how to get it to stop. It just keeps going. Also, I have edge_btn rotating the entire time in the beginning of the timeline.

[Code]...

View 0 Replies

ActionScript 2.0 :: How To Stop Moving Object

Dec 13, 2006

I am making a new site, and was making buttons that looked a little similar like this buts on the left) and wanted that to do with Actionscript.I followed a tutorial on Kirupa on moving stuff with actionscript

Code:
onClipEvent(enterFrame) {
speed = 30;

[code].....

View 5 Replies







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