It might be easier to convince Erin to code it in Actionscript from now on 🙂
2.0.1 Optimized (UPDATE: Now with less fail!)
FlashIf I had the time, I'd change so much stuff about Box2DFlash, to make it more accessible to the average Flash developer, and simply because Flash doesn't work the same way as C++ (different feature set, optimization requirements etc).
- The b2's should go. They just make more effort for everyone, and namespacing is a much better replacement for them.
- Definitions and factories are somewhat pointless when Flash doesn't have sophisticated memory management, so I'd merge them. You can just check if the bodys m_world property is set to see if you need to add or copy it.
- I'd add even more getter/setter properties (or whatever the terminology for them is). I'd get rid of the old Get/Set methods, except maybe for backwards compatibility.
- All the fixed sized arrays need to be replaced with variable ones, and stop initializing them with objects they don't need.
- Internally, it seems a lot of arrays need to be replaced with linked lists and trees, given (apparently) that native arrays are log n lookup.
- The testbed example need to have a floating timestep, as per best practise, and also have the minimal framework in place for using sprites instead of debugDraw. It is a fact most people will take the example as the basis for their own projects, so it should be good, not minimal.
- Perhaps implement "controllers" as discussed in some other thread.
Well, whether or not it does anyone any good, I started on it:
http://code.google.com/p/box2dflash/
There's a working example of the syntax here: http://box2dflash.org/node/7 (the source is included as a Flex archive in the examples folder)
And there you have it 😀
http://code.google.com/p/box2dflash/
There's a working example of the syntax here: http://box2dflash.org/node/7 (the source is included as a Flex archive in the examples folder)
And there you have it 😀
Would you like a copy of my port using the b2Internal namespace for all variables that the C++ version declared private or protected? It increased the compile failure rate for some people in Flash CS3 (which is really Adobe's/Macromedia's fault), so I'm back to using public variables everywhere for now, but I get the feeling your target audience isn't using Flash CS3.
(I'm secretly pretty excited about improving the accessibility of Box2D Flash, though I'm cautious about making it official for the reasons I've said already)
(I'm secretly pretty excited about improving the accessibility of Box2D Flash, though I'm cautious about making it official for the reasons I've said already)
I actually used your copy from earlier in the thread if that's the one you're referring to. (although I think I actually butchered some of the namespaces with my mass "b2" find and replace)
Yeah, that was what I meant, nice! ... and yes, now it's the "Internal" namespace. 😛
It might be worth changing the name of your project, so as not to confuse people with many different projects all called Box2D Flash.
It might be worth changing the name of your project, so as not to confuse people with many different projects all called Box2D Flash.
I'll make sure and distinguish where I can (the first line in the project description is now a link to the official sourceforge page), but I already committed to the box2dflash.org domain name and project name for google (they don't allow project name changes).
Do you have any suggestions other than that?
Once I get the syntax "conventionalized" a little more, I plan on putting some "getting started" tutorials up on box2dflash.org that are more goal oriented than just pure documentation. I have to admit that Erin has done an amazing job documenting Box2d.
Do you have any suggestions other than that?
Once I get the syntax "conventionalized" a little more, I plan on putting some "getting started" tutorials up on box2dflash.org that are more goal oriented than just pure documentation. I have to admit that Erin has done an amazing job documenting Box2d.
pv3d: Please don't fork the project, then keep the same name. Surely you can see that is going to be annoying and confusing? Keep the domain name and google project name if you must, but at least append something like "Reloaded" or "Streamlined" to the name. For the record, I consider any variant of /Box2D(Flash)?(AS3)?/i to describe the current Flash port. If you want the streamlined copy to be considered the authority, it'd be better to discuss it here first, and in particular, skatehead.
In general, forks should not be entered into lightly. There are very few developers for the Flash version, particularly as skatehead is MIA, so I doubt there is enough general willpower to keep both in step with Box2D. But if you want to do it yourself, I'm not going to stop you.
In general, forks should not be entered into lightly. There are very few developers for the Flash version, particularly as skatehead is MIA, so I doubt there is enough general willpower to keep both in step with Box2D. But if you want to do it yourself, I'm not going to stop you.
sorry for the stupid question, maybe the answer is so easy...
Why when i tried compiling helloworld.fla I got the following errors????
Why when i tried compiling helloworld.fla I got the following errors????
Code:
**Error** C:\Documents and Settings\nsirago\My Documents\Flash\box2DFlashAS3v2-0-1\HelloWorld.as, Line 74: 1061: Call to a possibly undefined method CreateStaticBody through a reference with static type Box2D.Dynamics:b2World.
body = m_world.CreateStaticBody(bodyDef);
**Error** C:\Documents and Settings\nsirago\My Documents\Flash\box2DFlashAS3v2-0-1\HelloWorld.as, Line 96: 1061: Call to a possibly undefined method CreateDynamicBody through a reference with static type Box2D.Dynamics:b2World.
body = m_world.CreateDynamicBody(bodyDef);
**Error** C:\Documents and Settings\nsirago\My Documents\Flash\box2DFlashAS3v2-0-1\HelloWorld.as, Line 109: 1061: Call to a possibly undefined method CreateDynamicBody through a reference with static type Box2D.Dynamics:b2World.
body = m_world.CreateDynamicBody(bodyDef);
Total ActionScript Errors: 3, Reported Errors: 3
Have you a stable version of your work, or a quick reply to me?body = m_world.CreateStaticBody(bodyDef);
**Error** C:\Documents and Settings\nsirago\My Documents\Flash\box2DFlashAS3v2-0-1\HelloWorld.as, Line 96: 1061: Call to a possibly undefined method CreateDynamicBody through a reference with static type Box2D.Dynamics:b2World.
body = m_world.CreateDynamicBody(bodyDef);
**Error** C:\Documents and Settings\nsirago\My Documents\Flash\box2DFlashAS3v2-0-1\HelloWorld.as, Line 109: 1061: Call to a possibly undefined method CreateDynamicBody through a reference with static type Box2D.Dynamics:b2World.
body = m_world.CreateDynamicBody(bodyDef);
Total ActionScript Errors: 3, Reported Errors: 3
@Boris- I have no intentions for this branch to be considered the authority (unless that's what skatehead wants) and I'll gladly tack on some adjective to distinguish the two versions. I'll probably just call it "Box2dFlash Refactored" as that's really all I've done. Erin, skatehead, and shaktool have done all the hard work.
As for keeping up with Box2D, my hope is that "Refactored" will draw more developers in with the friendlier syntax. It may or may not happen, but it's a risk I'd rather take.
As for keeping up with Box2D, my hope is that "Refactored" will draw more developers in with the friendlier syntax. It may or may not happen, but it's a risk I'd rather take.
Original thread: https://box2d.org/forum/viewtopic.php?t=908