ActionScript 2.0 :: Detect Collision Between A Point?
Jun 25, 2008Because I want to detect collision between a point and an MC contained within another MC.
View 1 RepliesBecause I want to detect collision between a point and an MC contained within another MC.
View 1 RepliesI've found the BitmapData.hitTest() function very handy, but limited for my purposes. I need to figure out at exactly which point the two images collide (in any coords system,really), since their behaviour will change depending on the angle of the surface hit
View 9 RepliesI want to detect when a circle collides into a random object. I know this is pretty basic to do with a mouse colliding into a random object but I want to modify this for a circle. I have seen some examples which use circles but they are drawn in script, is it possible to do this with a mc from the library.
View 2 Repliesim creating a circle dynamically with each click on stage, with the drawCircle function, now, that circle is a shape, not a movieClip, im arranging this circles inside of an array, and i want to check if they collide, so that second circle dont appear if its occupying the same space as the last one, or at least trace if they are colliding so i can do something about it....
i've made tests with movieClips and no problem, the mc1.hitTestObject(mc) works great but not so great with raw shapes, it just ignores collisions
Is there a way to detect what movie clip is in a certain location? For instance, if I enter some random coords, like x=15, y=0, is there a way it will return the name of the movieclip thats occupies that location?
View 1 Replieswhat i am trying to do is to detect a collision between an empty mc and an mc allready in stage.the empty mc is a line, which I draw with the mouse. when this line hits the other mc I want the colission to be detected. so far it doesnt work properly.the colision is being detected even if the line that i draw, doesnt hit the other mc. does it have to do with the properties of the empty mc, or the hittest method has to be changed?Here is the code:
_root.mc.onEnterFrame=function(){
if(_root.mc.hitTest(_root.line)){
thingstohappen;}
Take a look at this scenario, I have two characters, one shoots two bullets on the direction of the other character, the bullets are fired instantly and travel at infinity speed, how to detect a collision? Here's an image to illustrate the problem: The red bullet would clearly miss, but the green bullet would hit, how to perform this kind of collision test?
View 1 RepliesMy collision detection is solid when I put 2 images against each other but when I put 1 image against another image's child I can't get a collision. Whats the deal? Do I have to add the child independently of its parent?
View 3 RepliesIf you have a group of movie clips stored in an array and the movie cliops are placed on the stage randomly, and use your arrow keys to move a box on top of one of the movie clips - how can you "tell" Flash which movie clip you clicked on?
Right now I've got a for loop going which loops through the array that has stored the movie clip instances, presumably the hitTestObject would eventually get a hit...But this doesn't work, especially inside an event handler where when I press the right arrow on my keyboard.
[Code]...
I got a working broad phase and collision detection is fast enough.Now my collision response is working, but slow. I have trace(using getTimer()) through the whole resolving method, and I found the slow spot is where I get the collision point and normal vector.
Right now, I test each point on each shape against each line on the other shape. This works nice on triangles, but other shapes, it much to slow.I would think that using SAT(seperating axis therom) would have a way to get this when checking collisions, but I cant seem to get it.I need a fast way to get the collision point and normal vector.(Right now, it takes about 3 milliseconds per collison on a rectangle with 4 points and 4 lines)
I need to know what side of a rotated box my sphere/point is colliding with and at what angle.
I could perform the 4 lines check but I think it will be too cpu consuming. I need it for fast simple physics simulations(bounces)..
i have two movie clips mcTrap and mcCharacter.how can i detect collision (character is fully inside) over the trap door?
View 1 RepliesSo in my game, every 'enemy' movieclip creates a textfield that represents the name of the enemy. The problem is, I want my collision detect engine to detect a collision with the enemy itself, not the textfield. This is the code that I have currently have on my collision class for detecting a collision with the enemy:
for(var i = 0;i < _enemies.length; i++)
{
if(CollisionEngine.isColliding(_laser, _enemies[i]._enemyNameTextField, _animation))
[code]......
Does anyone know how to use hitTest with two movieclips so that it would detectthe collision of the visible part of the MC, not the **** bounding box???
View 2 RepliesRight now I'm working on an advanced hitTesting engine, and What I'm trying to do here is create an engine that will detect collision with one object instead of two. That basically means that if any other objects touch this movie clip, the hitTest will return True. Right now the .fla containing the engine has nothing but a circle that can be moved using arrow keys and 8 squares that disappear when touched by the circle. Obviously, I could do something like:
if (circle.hitTest(square1)) {
do so and so
} else if (circle.hitTest(square2)) {
do this and that
} etc...
But that would be too long, since the engine has to be able to contain 100 squares without too much change in the code.
i am listening contact between dynamic bodies. But cannot listen contact between dynamic and static bodies .
I can handle collision detection on my b2contactListener class with this metod.
public override function BeginContact(contact:b2Contact):void {
// getting the fixtures that collided
var fixtureA:b2Fixture=contact.GetFixtureA();
[Code].....
I got it working for using the e.target of the mouse but now I need to filter through the array on enter frame and detect whether a collision is detected.[code]
View 4 RepliesThere is some information but I couldn't figure it out:How can I detect if a line intersects with a triangle ? And how can I detect the point of intersection in AS3 ?
View 1 RepliesIn my file (AS2), I have a small square at the middle of the page. Diagonally to the right, I have a vertical wall which is a rectangle. Pasted inside my small square, I have the code:
onClipEvent(enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if (this.hitTest(Wall._x, Wall._y, false)) _x =
[code]......
Im pushing Point locations into an array to Shift em out later. like this:
tempmoves.push([new Point(roundx,roundy)]);
..
ob.movestoplayer = tempmoves;[code]....
What am i doing wrong?
It's been a long time since I've done any work with actionscript, and alas I've forgotten nearly everything. I've tried to look for a tutorial that would explain basic animation with actionscript, but the one that I found on Kirupa was no longer there.
Basically I'd like to do this:On the stage I have a movieclip and I'd like the movieclip to move along the x-axis to a certain point and then back to the starting point again. The moving speed of the movieclip should also be adjustable.
I'm creating a game in flash for a university project, and learning actionscript and programming as I go. I'm very much still at a beginner level - at the moment al I have is some actionscript for drawing rectangles and moving them about the screen. This is what I'm having trouble with at the moment: I have a class called 'Creature', and I want instances of it to interact with each other. I want them to do something when they come within a certain distance of another instance. And I want them to be able to pick a random other instance to get the location of, in order to do something with that information.
What I think I need is: A function for telling the distance between two (x,y) points.
A way of referencing the nearest other instance of the class. And a way of randomly selecting from all of the instances of the class.
How to convert 3d point to 2d point? I've found next formula in Internet(camera is situated in origin)
[Code]....
But these formulae give me strange result when z are less than zero(z<0) I need build line from A(100,100,100) to B (100,100;-100) As you can see these equations give really strange result when I try to convert B point in 2D dimension
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 )
I am using AS2 with Flash 8 Professional So, my problem is that I currently have a man in the middle of the screen, who shoots a line towards the mouse when I click. However, when I use hitTest to see if the line collides with another object, Flash recognizes the line as a large box if it is diagonal, so the hitTest isn't very accurate. The line only satys there for one frame, so I can't have the usual moving-bullet-style. I am either looking for a way to create an imaginary line with AS from the starting point to the mouse and beyond, and tell whether or not this line intersects with an object... or some other way that I haven't thought of to fix my problem. Keep in mind that the line rotates from a center point towards anywhere around it for 360 degrees.
View 1 Repliesif i have a movieclip or a sprite could i find (via code) where is its registration point compared to its top left point (no rotation included) ?
View 4 Repliesmy preloader bar isn't growing smoothly. it appears to jump from point to point -- and i want to make it smooth. you can see the example here at: [URL] would anyone mind taking a quick look at the file i've attached,
View 6 RepliesI 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;
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 RepliesHi I am trying to create an image scroller that just scrolls images from point a to point b on load horizontally in an infinite loop. I just used a code snippet to move it horizontally but don't how to get it to stop and at point b and loop again from a.
ActionScript Code:
game1.addEventListener(Event.ENTER_FRAME, fl_AnimateHorizontally_3);
function fl_AnimateHorizontally_3(event:Event)
{
game1.x += 20;
}