basically, i am positioning boxes of the same width and height in flash and tracing out all their X, Y, and rotation properties..
i then, put all those values inside an array and then generate the Box2D "terrain" from there..
Code:
function setUpBoxes():void
{
boxValues = [ [28.400000000000002, 386.5, 0],
[71.4, 386.5, 0],
[114.4, 386.5, 0],
[157.4, 386.5, 0],
[199.9, 386.5, 0],
[242.9, 386.5, 0],
[285.90000000000003, 386.5, 0],
[328.90000000000003, 386.5, 0],
[371.90000000000003, 386.5, 0],
[414.40000000000003, 386.5, 0],
[457.40000000000003, 386.5, 0],
[500.40000000000003, 386.5, 0],
[543.4, 386.5, 0],
[586.4, 386.5, 0],
[628.9000000000001, 386.5, 0],
[671.9000000000001, 386.5, 0],
[714.9000000000001, 386.5, 0],
[757.9000000000001, 386.5, 0],
[800.9000000000001, 386.5, 0],
[843.4000000000001, 386.5, 0],
[886.4000000000001, 386.5, 0],
[929.4000000000001, 386.5, 0],
[972.4000000000001, 386.5, 0],
[1015.4000000000001, 386.5, 0],
[1057.9, 386.5, 0],
[1100.9, 386.5, 0],
[1143.9, 386.5, 0],
[1186.9, 386.5, 0],
[1229.9, 386.5, 0],
[1272.4, 386.5, 0],
[1315.4, 386.5, 0],
[1358.4, 386.5, 0],
[1401.4, 386.5, 0],
[1444.4, 386.5, 0],
[1486.9, 386.5, 0],
[1529.9, 386.5, 0],
[1572.9, 386.5, 0],
[1615.9, 386.5, 0],
[1658.9, 386.5, 0],
[1701.4, 386.5, 0],
[1744.4, 386.5, 0],
[1787.4, 386.5, 0],
[1830.4, 386.5, 0],
[1873.4, 386.5, 0],
[1915.9, 386.5, 0],
[1958.9, 386.5, 0],
[2001.9, 386.5, 0],
[2044.9, 386.5, 0],
[2087.9, 386.5, 0],
[2130.4, 386.5, 0],
[2173.4, 386.5, 0],
[2216.4, 386.5, 0],
[2259.4, 386.5, 0],
[2302.4, 386.5, 0],
[2344.9, 386.5, 0],
[2387.9, 386.5, 0],
[2430.9, 386.5, 0],
[2473.9, 386.5, 0],
[2516.9, 386.5, 0],
[2559.4, 386.5, 0],
[2602.4, 386.5, 0],
[2645.4, 386.5, 0],
[2688.4, 386.5, 0],
[2731.4, 386.5, 0],
[2773.9, 386.5, 0],
[2816.9, 386.5, 0],
[2859.9, 386.5, 0],
[2902.9, 386.5, 0],
[2945.9, 386.5, 0],
[2988.4, 386.5, 0],
[3031.4, 386.5, 0],
[3074.4, 386.5, 0],
[3117.4, 386.5, 0],
[3160.4, 386.5, 0],
[3202.9, 386.5, 0],
[3245.9, 386.5, 0],
[3288.9, 386.5, 0],
[3331.9, 386.5, 0],
[3374.9, 386.5, 0],
[3417.4, 386.5, 0],
[3460.4, 386.5, 0],
[3503.4, 386.5, 0],
[3546.4, 386.5, 0],
[3589.4, 386.5, 0],
[3631.9, 386.5, 0],
[3674.9, 386.5, 0],
[3717.9, 386.5, 0],
[3760.9, 386.5, 0],
[3803.9, 386.5, 0],
[3846.4, 386.5, 0],
[3889.4, 386.5, 0],
[3932.4, 386.5, 0],
[3975.4, 386.5, 0],
[4018.4, 386.5, 0],
[4060.9, 386.5, 0],
[4103.900000000001, 386.5, 0],
[4146.900000000001, 386.5, 0],
[4189.900000000001, 386.5, 0],
[4232.900000000001, 386.5, 0],
[4275.400000000001, 386.5, 0],
[4318.400000000001, 386.5, 0],
[4361.400000000001, 386.5, 0],
[4404.400000000001, 386.5, 0],
[4447.400000000001, 386.5, 0],
[4489.900000000001, 386.5, 0],
[4532.900000000001, 386.5, 0],
[4575.900000000001, 386.5, 0],
[4618.900000000001, 386.5, 0],
[4661.900000000001, 386.5, 0],
[4704.400000000001, 386.5, 0],
[4747.400000000001, 386.5, 0],
[4790.400000000001, 386.5, 0],
[4833.400000000001, 386.5, 0],
[4876.400000000001, 386.5, 0],
[4918.900000000001, 386.5, 0],
[4961.900000000001, 386.5, 0],
[5004.900000000001, 386.5, 0],
[5047.900000000001, 386.5, 0],
[5090.900000000001, 386.5, 0],
[5133.400000000001, 386.5, 0] ];
var terrainBody:b2BodyDef = new b2BodyDef();
terrainBody.position.Set(0, 0);
var theTerrain:b2Body = theWorld.CreateBody(terrainBody);
for (var i:int = 0; i < boxValues.length; i++)
{
var boxX:Number = boxValues[i][0];
var boxY:Number = boxValues[i][1];
var boxRotation:Number = boxValues[i][2];
// box shape...
var boxShape:b2PolygonDef = new b2PolygonDef();
boxShape.SetAsOrientedBox(ptm(22), ptm(7), new b2Vec2(ptm(boxX), ptm(boxY)), boxRotation * Math.PI / 180);
boxShape.density = 0;
boxShape.friction = 10;
boxShape.filter.groupIndex = -2;
theTerrain.CreateShape(boxShape);
}
theTerrain.SetMassFromShapes();
}
if anyone has a suggestion on a better / more efficient way of creating terrain, please let me know..
i need to get this done ASAP, i will be submitting a prototype by wednesday.. so please.. i need some help...