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

mayobutter:
Quote:
The native AS3 port and this one (Alchemy) are fundamentally different (AS3 vs C++).


Read up on this alchemy business, and I see what you mean.
Can I ask how easy it is for you to 'port' new files? Is just like running a compiler or do you need to actually change the c++ files?

Also, I wonder what made the Box2DFlash unsuitable for your game?

Anyways, thanks for clearing that up.
WOW. Great work. I've tried this box2d port with Flex SDK and FlashDevelop. It worked.

Small question, type of the debug variable in b2World can be Sprite, why did you make it MovieClip?
I've ported box2dflash TestBed. Here it is: http://megaswf.com/view/97dd72e9c063161 ... 0f094.html
Source code for FlashDevelop and FlexSDK is attached. I've also slightly modified b2World.as to make DebugDraw more useful, now it draws shapes in different colors and draws joints.
May be a bug: I added this code to b2World.DrawDebugData function
Code:
for (var c:b2Contact = GetContactList(); c; c = c.GetNext()){
   var fixtureA:b2Fixture = c.GetFixtureA();
   var fixtureB:b2Fixture = c.GetFixtureB();
   trace(fixtureA, fixtureB);
   var cA:V2 = fixtureA.m_aabb.aabb.getCenter();
   var cB:V2 = fixtureB.m_aabb.aabb.getCenter();
   DrawSegment(cA, cB, color);
}

and found that fixtureA and fixtureB are always null.
roman_m: Yes, it was a bug in b2ContactManager. I just uploaded a fix, which also patches a bug in b2Polygon::SetAsBox().

Also moved hosting to Github so I can commit these little fixes faster.

Thanks for the test bed / debug draw code! I'm going to look this over and probably include it in the next update.
mayobutter wrote:
roman_m: Thanks for the test bed / debug draw code! I'm going to look this over and probably include it in the next update.

If so, here is the updated version.
Attachment:
box2d-alchemy-test.zip [18.3 KiB]
Downloaded 44 times


One small question: now when I remove a body, it's joints don't get removed, so I have to remove them manually. Is this right?
Actually if you destroy a body, that should automatically destroy the joint. Are you getting different behavior?
mayobutter wrote:
Actually if you destroy a body, that should automatically destroy the joint. Are you getting different behavior?

Yes. Try commenting out line 111 in Test.as
Code:
joint.destroy();

and in testbed point on some body with joints and push 'D'.
Nice, all the compiler warnings are gone! Having to hit F5, then wait, then hit it again to bypass the warnings in order to test my project was getting tedious 🙂

[Think I figured this out, see EDIT below] Some questions regarding the raycasting functionality you just added... is it possible to get more control over how many or which (closest vs farthest) intersecting fixtures are returned? I think the C++ version allows this, right? And also possibly some way to do filtering--although if we could get multiple fixtures returned then I could probably just filter them myself after the callback. For context, I'm trying to use raycasting as rudimentary "vision" for a character. However I need the rays to not contact his own body and instead travel through him and collide with his environment.

EDIT: Actually disregard that last paragraph--you can specify whether to continue the ray in the return value of your callback function, correct? 0 to stop, 1 to continue, right? Do any other values have different behavior?

Anyway, this port keeps getting better and better as more features are added; thanks again for your work mayobutter.
I finaly decided to jump ship to this port last night and boy am i not disappointed, appart from me gettin confused with the differences between v2.0 and v2.1 (especialy contactlisteners!) everything ported over fine.

And of course we get all the goodies and extra speed, i find my frame rate is a lot more stable now.. and can handle more objects.

So thank you very much mayobutter.

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