2011-06-09

QuickB2 Joints behaving differently in different version of Flash player

This is an issue that I had recently that was so mind-numbingly random that it caused me to create this blog.

Basically, I had a quickB2 game that I was developing in FDT 4; it looked fine when I would build it, but when I went to pop it into a web wrapper, all the joints break!

Why?

...I don't know. For some reason, quickB2's joints get built differently in different versions of Flash Player. My local debug player was 10.1, but my web browser's was 10.3. Somehow, that made a difference. I haven't tested all the different version to see what happens with them, but if you come across this problem, the issue is with the joint contructors.

When building for older Flash players, the joints want relative coordinate points in their constructors. So to join 2 shapes together with a distance joint, we would use:

var joint: qb2DistanceJoint = new qb2DistanceJoint(shapeA, shapeB, new amPoint2d(0, 0), new amPoint2d(0, 0));

The 2 amPoint2d parameters are relative to the object's positions, so this would join them to each other's centres. (their [0,0]s)

However, with newer Flash players, the joints want global coordinates, so we can get the centres of each with their position parameter:

var joint: qb2DistanceJoint = new qb2DistanceJoint(shapeA, shapeB, shapeA.position, shapeB.position);

So, my advice is to go with the way newer Flash players want it; but the point I am really trying to make here is that if your project behaves differently between players, this might be why. Might save you a bit of hair-pulling. If I ever find out why this happens or is even possible, I will let you know! But for now, I just wanted to get this info out on the web, so the next poor guy that this happens to might save a bit of time.

No comments:

Post a Comment