creatubg a body class based off mayobutters example (yes im aware im using an older box2d) but its telling me
Quote:
1046: Type was not found or was not a compile-time constant: b2PolyDef.
Code:
package
{
import Box2D.Common.Math.b2Vec2;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.b2Body;
import Box2D.Dynamics.b2BodyDef;
import Box2D.Common.Math.b2Math;
import flash.display.MovieClip;
import flash.events.Event;
/**
* ...
* @author useruser3
*/
public class Body extends MovieClip
{
public var body:b2Body; // the b2 body
public var bodyDef:b2BodyDef; // the b2 body def
[Inspectable(defaultValue=1)]
public var density:Number = 1;
public function initialize()
{
var r:Number = rotation; //gets rotation as number
rotation = 0; //sets the rotation to 0
bodyDef = new b2BodyDef(); // sets bodyDef as a new b2body def
bodyDef.position.Set(x, y); //sets the position of the bodydef to the value of x and y
bodyDef.rotation = r * Math.PI / 180;
createShapes(bodyDef);
bodyDef.isSleeping = isSleeping;
//body
body = (parent as World)._world.CreateBody(bodyDef);
body.m_userData = this;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function onEnterFrame(event:Event)
{
var point:b2Vec2 = b2Math.SubtractVV(body.m_position, b2Math.b2MulMV(body.m_R, body.m_center));
x = point.x;
y = point.y;
rotation = (body.m_rotation * 180) / Math.PI;
}
public function createShapes(b:b2BodyDef):void { }
public function polygon(points:Array, x_pos:Number = 0, y_pos:Number = 0, rot:Number = 0):b2PolyDef {
var s:b2PolyDef = new b2PolyDef();
s.vertices = [];
for each(var p:Array in points) {
s.vertices.push(new b2Vec2(p[0] * scaleX, p[1] * scaleY));
}
s.vertexCount = points.length;
s.localPosition = new b2Vec2(x_pos * scaleX, y_pos * scaleY);
s.localRotation = rot * Math.PI / 180;
s.density = density;
return s;
}
}
}
{
import Box2D.Common.Math.b2Vec2;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.b2Body;
import Box2D.Dynamics.b2BodyDef;
import Box2D.Common.Math.b2Math;
import flash.display.MovieClip;
import flash.events.Event;
/**
* ...
* @author useruser3
*/
public class Body extends MovieClip
{
public var body:b2Body; // the b2 body
public var bodyDef:b2BodyDef; // the b2 body def
[Inspectable(defaultValue=1)]
public var density:Number = 1;
public function initialize()
{
var r:Number = rotation; //gets rotation as number
rotation = 0; //sets the rotation to 0
bodyDef = new b2BodyDef(); // sets bodyDef as a new b2body def
bodyDef.position.Set(x, y); //sets the position of the bodydef to the value of x and y
bodyDef.rotation = r * Math.PI / 180;
createShapes(bodyDef);
bodyDef.isSleeping = isSleeping;
//body
body = (parent as World)._world.CreateBody(bodyDef);
body.m_userData = this;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
public function onEnterFrame(event:Event)
{
var point:b2Vec2 = b2Math.SubtractVV(body.m_position, b2Math.b2MulMV(body.m_R, body.m_center));
x = point.x;
y = point.y;
rotation = (body.m_rotation * 180) / Math.PI;
}
public function createShapes(b:b2BodyDef):void { }
public function polygon(points:Array, x_pos:Number = 0, y_pos:Number = 0, rot:Number = 0):b2PolyDef {
var s:b2PolyDef = new b2PolyDef();
s.vertices = [];
for each(var p:Array in points) {
s.vertices.push(new b2Vec2(p[0] * scaleX, p[1] * scaleY));
}
s.vertexCount = points.length;
s.localPosition = new b2Vec2(x_pos * scaleX, y_pos * scaleY);
s.localRotation = rot * Math.PI / 180;
s.density = density;
return s;
}
}
}