Hey, I'm excited about this Box2D Flash port, but I'm not a programmer. I'm more of a simple flash designer/developer and I'm having a hard time figuring out how to apply the code in the bridge example to include images and Flash movie clips from the Flash environment Library.
It's really simple, what I want to do. I just want to have some Flash button symbol instances on the stage, and at runtime have the Box2D engine apply physics to the buttons to make them drop and scatter on the bottom of the stage.
Is there a simple way to do this? It seems the Box2D engine deals with vector geometry and doesn't have the ability to include any symbols directly from the Flash Library.
Any help is greatly welcomed 🙂
The vector stuff is part of the example, rather than part of the engine.
If you're not a developer, you might encounter a bit of a challenge getting this up and running using the example that came with it. If you like, I can write up an empty harness for bringing in MovieClips. I'd have to put it together after work, though.
Hi Andrew Traviss
I would really appriciate an example where you add e.g. a square or triangle from the library and add the physics to it.
Thanks in advance!
Hi,
Im new here. Just some basic questions, if anybody can help.
1. How do we use Box2D flash with Sprite or Movie Clip?
2. Where are the drawing for the shapes in the demos done? I don't see any usage of Flash drawing tools ya.
The attached class takes care of most of it for you. Create your sprite/movieclip, and pass it in via attachAvatar. Once you've done that, you just need to call updateAvatar, usually on ENTER_FRAME. If it does not seem to respond to forces applied, then pass in a lower density, or apply higher forces. This example uses the bounding box of the movie clip to create the matching physics object. You can extend this class and override the buildShapes function to change this.
Note: I changed all box2D package names for my personal use. This version of the class uses the old package names, for your convenience, but I may have messed up the conversion. Should be relatively easy to fix though.
Let me know if you run into any problems. Sorry for the long delay. Busy time of year.
Hi guys,
Does anybody know how to get reference to a MovieClip in a Library from an actionscript script file?
The neatest way, I can think of is loading it from another SWF file.
Yep, just remember that we're defining a class and not a field.
Thus all classes should be capitalized, as
private var BodyClass:Class;
You're right! My coding naming standards have gotten a bit out of whack with this project. I find myself sometimes
trying to be consistent with the box2d library, but other times slipping into community standards.
when it comes to box2d, all capitalization standards are out the window 😉