I'm trying to make a 'simple' rolling ball respond to accelerometer axis tilts in quickBox2D and it's proving illusive. I tried this using the wcg library for making box2D 'components' within Flash IDE, and it worked fine using code like this: responding to an accelerometer update event:
but no such value as 'baseGravity" exists in quickBox2d, and it doesn't have a SetGravity() function. The closest thing I could find in the QuickBox2D class was:
but calling myWorld.gravity(the new b2Vec2), just throws an error:
The Intro to QuickBox2D part 2 has section titled gravity which shows the following method:
but that just make things weird when accelerometer events/values are used, and stone dead when resetting value to 0, before changing, even when including a call to.
This seems to basic to be causing this much trouble. What am I missing?
Code: Select all
newGravity = new V2(-e.accelerationX*20, e.accelerationY*20);
myWorld.baseGravity = newGravity;but no such value as 'baseGravity" exists in quickBox2d, and it doesn't have a SetGravity() function. The closest thing I could find in the QuickBox2D class was:
Code: Select all
private var _gravity:b2Vec2;
/** The world gravity vector. This can be changed during runtime. */
public function set gravity(v:b2Vec2):void{
_gravity = v;
w.SetGravity(_gravity);
}but calling myWorld.gravity(the new b2Vec2), just throws an error:
.1195: Attempted access of inaccessible method gravity through a reference with static type com.actionsnippet.qbox:QuickBox2D.
The Intro to QuickBox2D part 2 has section titled gravity which shows the following method:
Code: Select all
stage.addEventListener(MouseEvent.CLICK, onClick);
function onClick(evt:*){
sim.gravity.x += 3;
}but that just make things weird when accelerometer events/values are used, and stone dead when resetting value to 0, before changing, even when including a call to
Code: Select all
world.updateBodies();This seems to basic to be causing this much trouble. What am I missing?