quickBox2D simple gravity change isn't simple-nothing reacts

Discuss issues specific to the Flash/AS3 port of Box2D
Posts: 1
Joined: Fri Sep 28, 2012 11:56 am

quickBox2D simple gravity change isn't simple-nothing reacts

Postby randy.paris » Fri Sep 28, 2012 1:18 pm

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:

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;

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


This seems to basic to be causing this much trouble. What am I missing?

Return to “Flash”

Who is online

Users browsing this forum: No registered users and 1 guest