Flash :: Box2d, Detect Collision Between Static And Dynamic Bodies?

Apr 12, 2011

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].....

View 1 Replies


Similar Posts:


Actionscript 3 :: Box2d - How To Find Nearest Bodies

Feb 5, 2011

I am trying to detect bodies which are near current. To do it, I've created quite a big collision shape, around the current body, and made it sensor. Collision event was triggered, but it's not what I need. Main thing is that collision event is called only first time when another body entered the detection field... And I want to be able to detect changes in bodies location, after it. (I am considering the fact that other bodies are moving inside detection field)

View 1 Replies

Flash :: Movie-style Shotgun Blast (sticky Collision) With Box2D?

Jan 29, 2011

I'm making a Flash game where the player throws balls of mud at objects in the sky. I'm using Box2D to model the physics. I don't want the ball to bounce off of objects (apply a normal force); instead I want it to impart its momentum on the object it is striking (like a movie-style shotgun blast).

View 1 Replies

ActionScript 3.0 :: Box2D Collision Categories - How To Work

Jan 13, 2011

I still have problem understanding how the collision category works. I'm only able to make it work by experimenting which is not good.

[Code]...

this works the way I wanted but only because I experimented around and found the right values (or at least values that work). I would prefer to know how the whole system works

View 6 Replies

Box2D - How To Get Position Of Static Object

Apr 14, 2011

I'm using sensors in a Box2D project. On a collision with a sensor, I'd like to know the sensor's position in the world. I'm detecting the collision with a contact listener, but the sensor's position is always 0 0.

From my code: (edit, added the whole class)
public class MyContactListener extends b2ContactListener {
public var onSensorEvent:Function;
override public function BeginContact(contact:b2Contact):void {
if(contact.GetFixtureA().IsSensor()) {
var ud1:GameEntity = contact.GetFixtureA().GetBody().GetUserData();
[Code] .....

View 1 Replies

ActionScript 3.0 :: Box2d Addchild - 41061: Call To A Possibly Undefined Method AddChild Through A Reference With Static Type Class

Jan 16, 2012

I have downloaded Box2d ([URL]) and created a project that looks like this: [URL]. catalyst is the green cube and it has the base class "shapes.box", it is inside "world" which has the base class "wck.World". What i want to do is to add another "catalyst" from the library inside "world" when i click on add_btn. I tried to accomplish this by this code:

[Code]...

Symbol 'buttons', Layer 'Actions', Frame 1, Line 41061: Call to a possibly undefined method addChild through a reference with static type Class.

View 9 Replies

ActionScript 2.0 :: CS3 Collision Of A Moving And A Static Object?

Jan 2, 2010

I have three objects in the main scene (so far), one of them is draggable (up and down only), then the animated one that moves downwards and the start button (activates the animation). So I've been trying to figure out how to script the collision detection for the first two? The collision should take place not because I dragged the slider onto the animated block, but because the falling piece hits the slider after I pressed the start button.

View 4 Replies

ActionScript 3.0 :: Detect Collision Between 2 Shapes?

Nov 12, 2009

I 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 Replies

ActionScript 3.0 :: Detect Collision Of Non-Movieclips?

Feb 10, 2010

im 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

View 4 Replies

ActionScript 2.0 :: Detect Collision At A Given Location?

Feb 24, 2005

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 Replies

ActionScript 2.0 :: Detect A Collision Between An Empty Mc?

Mar 28, 2005

what 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;}

View 1 Replies

ActionScript 2.0 :: Detect Collision Between A Point?

Jun 25, 2008

Because I want to detect collision between a point and an MC contained within another MC.

View 1 Replies

Actionscript 3 :: Bullet Hitscan - How To Detect A Collision

Jan 4, 2011

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 Replies

ActionScript 3.0 :: How To Detect Collision Of Image Child

May 17, 2011

My 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 Replies

ActionScript 3.0 :: Detect If There Is A Collision On An N Array Element?

Apr 9, 2011

If 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]...

View 2 Replies

ActionScript 3.0 :: Detect Collision (character Is Fully Inside) Over

Nov 5, 2008

i have two movie clips mcTrap and mcCharacter.how can i detect collision (character is fully inside) over the trap door?

View 1 Replies

Actionscript 3 :: Set Up Collision Detect So That It Ignores A Child Of The Target?

Feb 23, 2010

So 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]......

View 2 Replies

ActionScript 2.0 :: Use HitTest With Two Movieclips To Detect Collision Of The Visible?

Dec 12, 2002

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 Replies

ActionScript 2.0 :: Generic HitTest - Detect Collision With One Object

Oct 13, 2005

Right 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.

View 3 Replies

ActionScript 3.0 :: Filter Through Array On Enter Frame / Detect Whether Collision Is Detected

Jan 10, 2011

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 Replies

Flash :: Static Or Dynamic Linking Of .SWF Files

Feb 2, 2011

If you compile a Flash project into a .swf file and that project refers to another .swf file, is it linked statically or dynamically? That is, is the second .swf file contained physically in the first .swf file or does the first .swf file refer to the second at run-time?

View 1 Replies

Flash :: Dynamic Variable Names In Static Function?

Dec 14, 2011

Is there any way that you can have dynamic variables inside of a static function considering that you can't use "this" inside a dynamic function.

What I am trying to do:

public static function convertToDynamicString(pString:String):String
{
if(pString == "" || pString == null) return "";

[Code]....

View 3 Replies

ActionScript 2.0 :: F8 Cant Move Bodies Back And Forth

Apr 25, 2009

i want the body to move forward and back, without the head and legs moving. so it's kind of like a thrust i want to do, how do i do that

View 1 Replies

Flash - Paddle Movement Using Box2D?

Jan 3, 2011

I'm making a game like Arkanoid and to move the ship with mouse, I'm using the following code :

var mousex:int = costume.stage.mouseX;
if (mousex < paddleWidth/2)
mousex = paddleWidth/2;
else if (mousex > PhysiVals.STAGE_WIDTH - paddleWidth/2)

[code]....

Everything's going fine there! The paddle is moving the way it should! The problem is I want a little inclination towards the direction its moving and when it stops moving the angle of inclination should become zero.

View 1 Replies

ActionScript 3.0 :: Flash Box2D & 2D Shadows

Jul 24, 2011

I'm working on a AS3 Game Engine at the moment utilizing Box2D (2.1a) and 2D shadows. I have Box2D down but I've yet to find a way of drawing 2D shadows efficiently.I was following this tutorial only to be disappointed by the speed at which it rendered the Box2D shapes and the shadows.I was getting the vertices of the objects via this function:[code]And using it to draw the shadows via the AS3 graphics api.Can anyone recommend me a better more efficient way of programming 2D shadows?

View 2 Replies

ActionScript 2.0 :: Controlling Motion Of Entire Bodies

Apr 6, 2002

I have 2 questions:

(1) Is it possible to attach a more complex shaped body as one of the links, and still be able to control it as a line in circular motion? (for a clearer idea see URL...

(2) When you try to change the connector or follower lengths, the line lengths do not changed, even though they have been scaled to the distance between the points.

View 14 Replies

Flash :: Change Center Of Rotation Box2d?

Feb 13, 2011

I have a b2PolygonShape body and apply a force to it.

_recbody->ApplyForce( b2Vec2(6.0, -6.0), _recbody->GetWorldCenter() );

I want to change the centre of rotation of the body to be more in the front of the body. So that applyForce and also collisions make the body not turn in the centre but more in the front.

View 2 Replies

Flash - Drawing Custom Polygons In Box2D?

Apr 14, 2011

I'm making a Flash game, and I've encountered a really weird problem while trying to draw a polygonal shape in Box2D.

Here's the code I use:

var fixtureDefs:Array = new Array();
...
var fDef:b2FixtureDef = new b2FixtureDef();
fDef.density = 0;

[code]....

Where vertexArray is a valid array containing 4 b2Vec2 vertices, making up a convex shape.The problem is, when I test, collisions don't work right for that body. Most other objects -enemies, user-controlled characters - pass straight through, as if the body isn't there at all. Some raycasts pass through as well.

Infuriatingly enough, one kind of bodies I have (a custom enemy) somehow does detect the body and collides with it. The raycasts that particular kind of enemy attempts do work - when your character hides behind the polygon, it's like they can't see him.The other weird thing: when I try the same code, only go for SetAsBox instead of SetAsArray, it works exactly as it should.I'm using a custom ContactListener class, but I haven't done any contact filtering (unless it's possible to do that without realising).I'm using the Flash 9 version of Box2D 2.1a.

View 2 Replies

Rotating And Throwing Objects Using Flash And Box2D 2.1a?

Jul 26, 2011

i'm using flash with box2D 2.1a. i'm rotating ball hanging on the string. The path which the rotating ball trace is ellipse. When releasing the rotating ball from the string i want the ball to fly with the obtained direction, velocity and strength. As you can see in the pictures.[URL]..I've tried to do it with setPosition (method of b2Body) and with various joints. But I haven't got the needed results.

View 2 Replies

Flash - How To Climb Up Or Stick To Other Objects In Box2D

Jan 12, 2012

I know that trying to model character movement in Box2D is always hard/impossible, but I'm trying to see if there's any way to make an user-controlled object that cleanly slides against other objects, going up or down, that makes it look like the character is climbing/walking up or a down. The character could be modelled as a circle if that simplifies matters, but I don't see how I could get this effect using just a circle with a joint motor.

There's a "wheel joint" in the C++ version of Box2d, which I suppose I could port to Flash, but I don't know if that would give the correct effect either. Another idea I had was to have the character do little jumps, based on the normal of the object that it is touching. But I suspect that at corners, or at contacts with multiple objects, this will give weird results.

View 1 Replies







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