I am going through the Hello World Video Tutorial and I am about 90% complete but I am always receiving an error.
I constantly receive when trying to compile "1061: Call to a possibly undefined method CreateStaticBody through a reference with static type Box2D.Dynamics:b2World."
Here is my code so far:
I am out of ideas, any help would be very much appreciated.
I constantly receive when trying to compile "1061: Call to a possibly undefined method CreateStaticBody through a reference with static type Box2D.Dynamics:b2World."
Here is my code so far:
Code:
import Box2D.Dynamics.*; // physics
import Box2D.Collision.*; // bounding box
import Box2D.Collision.Shapes.*; // define shapes
import Box2D.Common.Math.*; // for vector
import flash.display.*; // sprite class
var worldBox:b2AABB = new b2AABB();
worldBox.lowerBound.Set(-100,-100) // 1m = 30pixels
worldBox.upperBound.Set(100,100);
// gravity
var gravity:b2Vec2 = new b2Vec2(0, 10) // 300 pixels / per second sqaured
var bSleep:Boolean = true;
var myWorld:b2World = new b2World(worldBox, gravity, bSleep);
//define our shape
var boxDef:b2PolygonDef = new b2PolygonDef();
boxDef.SetAsBox(3,1); // 1 meter = 30 pixels, width 90, height 30
boxDef.friction = 0.3 // between 0 and 1
// define our body
var bodyDef:b2BodyDef = new b2BodyDef();
bodyDef.userData = new Sprite();
bodyDef.userData.width = 90;
bodyDef.userData.height = 30;
bodyDef.position.Set(5.5, 19) // x = 165, y = 300
addChild(bodyDef.userData);
var body:b2Body = myWorld.CreateStaticBody(bodyDef);
body.CreateShape(boxDef);
body.SetMassFromShapes();
// debug draw
var dbgDraw:b2DebugDraw = new b2DebugDraw();
dbgDraw.m_sprite = new Sprite();
addChild(dbgDraw.m_sprite);
dbgDraw.m_drawScale = 30.0;
dbgDraw.m_fillAlpha - 0.3;
dbgDraw.m_lineThickness = 1.0;
dbgDraw.m_drawFlags = b2DebugDraw.e_shapeBit;
myWorld.SetDebugDraw(dbgDraw);
var m_timeStep:Number = 1.0 / 24.0; // (1.0) steps per frame
var m_iterations:int = 10;
addEventListener(Event.ENTER_FRAME, Update, false, 0, true);
function Update(e:Event):void{
myWorld.Step(m_timeStep, m_iterations);
}
import Box2D.Collision.*; // bounding box
import Box2D.Collision.Shapes.*; // define shapes
import Box2D.Common.Math.*; // for vector
import flash.display.*; // sprite class
var worldBox:b2AABB = new b2AABB();
worldBox.lowerBound.Set(-100,-100) // 1m = 30pixels
worldBox.upperBound.Set(100,100);
// gravity
var gravity:b2Vec2 = new b2Vec2(0, 10) // 300 pixels / per second sqaured
var bSleep:Boolean = true;
var myWorld:b2World = new b2World(worldBox, gravity, bSleep);
//define our shape
var boxDef:b2PolygonDef = new b2PolygonDef();
boxDef.SetAsBox(3,1); // 1 meter = 30 pixels, width 90, height 30
boxDef.friction = 0.3 // between 0 and 1
// define our body
var bodyDef:b2BodyDef = new b2BodyDef();
bodyDef.userData = new Sprite();
bodyDef.userData.width = 90;
bodyDef.userData.height = 30;
bodyDef.position.Set(5.5, 19) // x = 165, y = 300
addChild(bodyDef.userData);
var body:b2Body = myWorld.CreateStaticBody(bodyDef);
body.CreateShape(boxDef);
body.SetMassFromShapes();
// debug draw
var dbgDraw:b2DebugDraw = new b2DebugDraw();
dbgDraw.m_sprite = new Sprite();
addChild(dbgDraw.m_sprite);
dbgDraw.m_drawScale = 30.0;
dbgDraw.m_fillAlpha - 0.3;
dbgDraw.m_lineThickness = 1.0;
dbgDraw.m_drawFlags = b2DebugDraw.e_shapeBit;
myWorld.SetDebugDraw(dbgDraw);
var m_timeStep:Number = 1.0 / 24.0; // (1.0) steps per frame
var m_iterations:int = 10;
addEventListener(Event.ENTER_FRAME, Update, false, 0, true);
function Update(e:Event):void{
myWorld.Step(m_timeStep, m_iterations);
}
I am out of ideas, any help would be very much appreciated.