AS3 2.1 Port (Alchemy), WCK Update and Kinematic Demos

itr77 wrote:
Edit: Another question - I think I need to edit the C code (hack to make revolute joints react slower than normal), is it possible to do this? I tried only including the 'Box2D' folder and discounting the SWC but this failed.

Not trying to be rude or anything, but this is kinda the point of having an AS3 port, it's easier to hack onto.
Update:

* Moved b2ContactListener and b2DestructionListener into their own classes.

* Introduced AS3 native contact & destruction events in the core Alchemy port (just set m_userData to be an EventDispatcher). I was originally going to keep the port as close to the C++ version as possible, but native AS3 events just feel so right. You can forgo this feature anyway by just using your own contact listener

* Fully implemented contact callbacks so they are closer to the C++ versions.

NOTE: If you want a fixture to report contacts, make sure to set "m_reportBeginContact", etc.

itr77: I added a TestBed that demonstrates getting the tangent & normal impulse from a contact.

If you want to hack the C++ source, first thing is you'll need to have Adobe Alchemy: http://labs.adobe.com/technologies/alchemy/
Then you'll be able to compile the C++ into the SWC from the command line with (from within the Box2DAS folder):

alc-on; g++ Box2D.c -I.. -O3 -Wall -swc -DOSX -o Box2D.swc; alc-off

There's no debugging available though so be prepared for a challenge.
BorisTheBrave wrote:
Not trying to be rude or anything, but this is kinda the point of having an AS3 port, it's easier to hack onto.


I understand - and if I needed to make any significant changes I'd most definitely be using it - but this is 3 lines of code 🙂

Thanks mayo!
Update:

Run Time Polygon Decomposition. This uses the code written by ewjordan in the C++ SVN Contributions folder, so hopefully that's pretty stable. It handled the shapes I threw at it pretty well. See the test bed for 2 examples.
I'm going to start with an apology as this may be a dumb / already covered question.

How do I get the b2DebugDraw class working with just the alchemy port ( I'm planning on using that directly rather than via WCK ) ? I'm working kinda blindfolded right now, so any help would be great ( I have looked at the testbed code, which does reference the b2DebugDraw class, but I can't find it as part of the Box2DAS package ).

Excellent work with this so far btw, it's really impressive.

Squize.
It's in Box2DAS/Dynamics/b2DebugDraw.as

Just pass the constructor your world and scale number and attach it somewhere on the stage.
How do i draw my own textures/shapes onto an object?

For example i have a circle, but i want to give it some funny arms or something thats just artistic detail that extends out of the circle shape (this doesnt have any physics). currently if i edit the movieclips to do this, it seems to treat anything i draw as a solid object and change the physics of the object.
"It's in Box2DAS/Dynamics/b2DebugDraw.as"

Cheers mate. Unless I'm going mental, I'm sure I downloaded it via a direct link on the wck page the other week which didn't include that file ( ? )

Anyway grabbed it from the github page, and all looking good, thanks for the reply, to which on the face of things, was a really badly stupid question 🙂

Squize.
Joobs wrote:
How do i draw my own textures/shapes onto an object?

For example i have a circle, but i want to give it some funny arms or something thats just artistic detail that extends out of the circle shape (this doesnt have any physics). currently if i edit the movieclips to do this, it seems to treat anything i draw as a solid object and change the physics of the object.

Look here: http://box2d.org/wiki/index.php?title=L ... _Box2D_AS3
This is about as3 port, but the logic is completely the same.
Joobs: Actually that is a very legitimate question regarding WCK. All of the demo objects use the built in, width / height detection to define the size of the shapes. So if you add some arms onto a circle, it will suddenly think that circle is much larger.

Here are the various ways you can explicitly specify the exact size of your shapes:

1. Create a new symbol that extends BodyShape, then within that symbol place another symbol that extends Circle (or another shape class) that is the exact dimensions you want. The inner symbol will define the shape, but the outer one will act as the body and can have whatever "decoration" graphics you need. You can nest BodyShapes as deep as you want. The top most one will work as the body.

2. Create a new symbol that extends BodyShape, define a custom class for it and override the shapes method like so:

Code:
public override function shapes():void {
       circle(30);
       /// box(20, 20), etc...
}


3. Create a new symbol that extends BodyShape, and define your shapes on the first frame of the timeline like so (this method is a bit dangerous though and may change):

Code:
shape(circle, 30);


The whole idea of the BodyShape class is that once you set up your symbols properly you can just drop them into whatever worlds you want. You can even combine BodyShape symbols into bigger "compound" BodyShapes.

Original thread: https://box2d.org/forum/viewtopic.php?t=4105