Actionscript 3 :: Find Contact Normal For Sensor In Box2d 2.1a

Mar 15, 2012

I am extending the b2ContactListener to find out the normals of my collisions. However, every time I get a contact with a sensor, the normal is always 0,0. How do I get the normal if one of the bodies is a sensor?

override public virtual function BeginContact( contact : b2Contact ) : void
{
var normal : b2Vec =

[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

ActionScript 3.0 :: Find The Normal(x,y,z) For A 3d Triangle?

May 11, 2011

In my quest to build a terrain with proper collision detection, I've reached another stalemate. What I need is to be able to find the normal(x,y,z) for a 3d Triangle. before I start to build everything from scratch, cross products and all that jazz. I want to check if someone's done this before or can give me their 2 cents of how to do this the best way.Given 3 verticles with (x,y,z): v1, v2, v3 How do I find the Normal(x,y,z)I'm using away broomstick, and as far as i can tell there's no support for normal calculation. You would think that .subGeometry.vertexNormalData returns the proper normal, but it doesn't.

View 14 Replies

Flex :: Display And Parse Sensor Data (text)?

Apr 5, 2011

I have a sensor that sends data as text file. Data format as follow: dat=110405120000+000.00+000.00+005.65+000.00+040.71+000.00+000.00+000.20.

How can i parse this data? The output i want is:

date: 05-04-11
time: 12:00:00
ch01: 000.00
ch02: 000.00

[Code].....

View 2 Replies

ActionScript 3.0 :: ''if" Statements When Dealing With A Stream Of Sensor Data?

Apr 17, 2010

After a not inconsiderable effort I've managed to get a touch sensor attached to a microprocessor talking to flash. It gives a constant analog input giving a value between 0 and around 300. When it reads 0, the sensor is being pushed hard enough, and my aim is to get an object to appear on the screen every time the sensor is pressed so that it reads 0.[code]Which works, when the sensor reads 0 it traces "zero", except it does it every time it reads the sensor, so there's huge great list of "zero"s generated.What i want is for it to trace "zero" only the first time it detects a zero, and not do it again until the value rises past zero and back down again.Is there a conditional way to do this? Something like "If previous value was greater than zero and this value is equal to zero, trace zero. if not, do nothing"?

View 2 Replies

Actionscript :: Flash - Ease Out Scrolling Moviclip, Scrolled By Sensor On Each Side?

Apr 9, 2010

I have a movieclip that is scrolled by means of a 'sensor' on each side of the stage. The clip scrolls fine in both directions, however here is my problem:When the users mouse leaves the stage, the movie clip stops dead in it's tracks, and this does not provide a nice smooth effect. Looking at the code below, is there any way I could tell the animation to ease out when the users mouse leaves the stage rather than simply stop suddenly?

class Sensor extends MovieClip {
public function Sensor() {
}

[code].....

View 1 Replies

ActionScript 2.0 :: Php Contact Form - Unable To Receive The Contact Email

Sep 26, 2008

the source files work perfectly when I upload them to my server - but when I insert the form into my flash website - I am unable to receive the contact email at all. The problem must be with the flash file becuase I have not altered the php (except to send to my email)

I am using Flash CS3 (but publishing for action script2) I have double checked all my input field sare named correctly with var_names that match the php code. The form fields have been created as a moviclip named "form" and the following action script attached:

[Code]....

View 7 Replies

ActionScript 3.0 :: How To Use Box2d

Oct 18, 2010

how to use Box2d?

View 4 Replies

ActionScript 3.0 :: Box2D HelloWorld With No FLA?

Aug 20, 2010

I recently did a quick demo on my site of Box2D (Box2DFlashAS3) with source code. Its basically just the HelloWorld example from the v2.1a distribution, but with a few tweaks. The most notable is that my version does not require a Flash FLA file to compile and run, its pure AS3. Simple and a good base to build on:

http:[url]........

View 3 Replies

Professional :: Box2D Not Working On IOS?

Dec 17, 2011

Anyone know how to get BOX2D physics engine working on iOS? It seems to work on the adl tester but not when I actually test it on the device.

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

Box2D - How To Make Conveyor Belt

Mar 2, 2011

Here: Flash game
There is a flash game called garbage separator. In this game, there is a conveyor belt.
With 2 Circles you can move the conveyor and I think you can use boxes with joint for belt but i dont know how to give it the form:
Circular Form
How to do this with Box2d?

View 1 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 How To Display Graphics

May 17, 2011

I have one question for your.This code I took from the site

ActionScript Code:
package {
import flash.display.Sprite;

[code]......

View 6 Replies

ActionScript 3.0 :: Click Over An Object In Box2D?

Nov 30, 2010

I need to click over an object in Box2D. Need to know which object i have clicked, and to delete that object. How could i know, which object i have clicked?..

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 3 :: How To Achieve A 1:1 Display Of Box2d Data

Nov 7, 2010

Anyone know how to achieve a 1:1 display of box2d data?I'm dividing all my values by a Physics.Scale value (30) but boxes I create like this:polyDef.SetAsBox(640 /Physics. scale, 32 / Physics.scale);Are still showing up much larger than 640 pixels wide and 32 pixels high.Weirdly, my AABB for the world is showing up perfectly at 640x480.[code]

View 1 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

Flash :: Box2d Body Shape Modification?

Jan 13, 2012

Is it possible to modify a shape within a body after assigning it, for example I have a box shape for my game hero body, and when I press the down arrow I want my hero to crouch witch means that I need the body shape to be resized.

I've already searched in google but it appears that the topic of modyfing shapes is not so popular. If it's impossible maybe you know a better way of doing this.

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

Actionscript 3 :: Movieclip Stops Rotating After It's Box2D Body

Nov 30, 2011

I have made a Car Game using Box2D [in Flash] and I have one remaining bug, which I cannot fix. I added graphics and put them on top of the Box2D body. Everything went as good as expected, but after X rotations the movie clips for the car-wheels, stop spinning. I do something like this wheelSprite.rotation = wheelBody.GetAngle() * 180 / Math.PI. I ran a separate program and I saw that, if you do X.rotation += variable and you increase the variable every frame, after ~30 000 (value of variable) the MovieClip stops rotating, so I reset it to 0 after ~28 000. What do I do? The wheelBody.GetAngle()

View 2 Replies

Flash :: Box2d B2BodyDef Have A Massdata Property In Cocos2D?

Mar 9, 2012

I want to know if box2d b2BodyDef has a massdata property or if it can be accessed in some way. I am not sure whether this can be done in Cocos2D but I have seen it in the flash code I am trying to re-implement in cocos2d.Here is the the code that brought about the question.

[Code]...

View 1 Replies

Flash - Create A Platform Body That Spins On It's Center In Box2D?

Feb 24, 2011

I'm trying to create spinning shapes floating in space. There is still gravity in the environment, however it should not affect these platform objects because they are static (right?). How can I apply a constant angularVelocity to it though? It doesn't seem to apply when I assign it a value, probably due because it's static.

The simplest example would be a spinning gear, an automated teeter-totter (not influenced by external forces). All I'm trying to make is a spinning rectangle that could interfere with a ball controlled by the user.Do I need to use Joints to pin it in place? How can I specify the details of not being influenced by the dynamic objects?

View 1 Replies

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

Flash :: Preventing Box2d Player From Pressing Against Walls In Midair

Nov 20, 2011

I have setup a box2d world with a keyboard controlled player. The player can walk and jump. How do I prevent the player from "sticking" to walls while jumping and pressing the directional key towards an object?

View 3 Replies

Actionscript 3 :: Box2d Is Freezing When EnableMotor Is Set To True On A Revolute Joint

Dec 8, 2011

I have a strange bug in an box2d project(AS3, box2d 2.1a).

I have a dynamic rectangle and a small static circle overlapping. I create a revolute joint to those 2 objects(located inside the center of the small circle, point which is also inside the rectangle). If enableMotor is set to false when the joint is created the scene works perfectly, with the rectangle hanging. When I set enableMotor to true the scene freezes.

View 1 Replies

Actionscript 3 :: Integrate With As3isolib Some Physic Engine Like Nape Or Box2d?

Feb 13, 2012

i just searching for any resource that explain or teach how integrate if it possible as3isolib with some physics engine like, nape or box2d. It is possible?

View 1 Replies







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