hello everyone,
ik have build this box2D platform game. but i would like tot creat levels more easily. whif out the bulkloader it work fine. only my file size will grow and grow when i use the preloader it only shows one of each movieClip
why is this and what can i do about it?
this is how i call my movieClips
this is how i creat my bodies
ik have build this box2D platform game. but i would like tot creat levels more easily. whif out the bulkloader it work fine. only my file size will grow and grow when i use the preloader it only shows one of each movieClip
why is this and what can i do about it?
this is how i call my movieClips
Code:
private function createLevelZero():void
{ //pleacing level 0
///upper stack
for (var x:int = 1; x<4; x++) { ///width of stack
_levelBuilder = new LevelBuilderActor(_background, _levelBuilderBlok, new Point(80 + (_LevelBoxSpacing * x) , 360), false,false)
_allActors.push(_levelBuilder);
}
///lowerstack
for (var x:int = 1; x<3; x++) { ///width of stack
_levelBuilder = new LevelBuilderActor(_background,_levelBuilderBlok ,new Point(380 + (_LevelBoxSpacing * x) , 400), false,false)
_allActors.push(_levelBuilder);
}
//angeled level part
_levelBuilder = new LevelBuilderActor(_background,_levelBuilderAngledBlok ,new Point(390, 350), true,false )
_allActors.push(_levelBuilder);
for (var i:int = 1; i < 3; i++) {//heigh of stack
_levelBuilder = new LevelBuilderActor(_background,_levelBuilderBlokVertical ,new Point(145, 350- (_LevelBoxSpacing * i)), false,true)
_allActors.push(_levelBuilder);
}
}
{ //pleacing level 0
///upper stack
for (var x:int = 1; x<4; x++) { ///width of stack
_levelBuilder = new LevelBuilderActor(_background, _levelBuilderBlok, new Point(80 + (_LevelBoxSpacing * x) , 360), false,false)
_allActors.push(_levelBuilder);
}
///lowerstack
for (var x:int = 1; x<3; x++) { ///width of stack
_levelBuilder = new LevelBuilderActor(_background,_levelBuilderBlok ,new Point(380 + (_LevelBoxSpacing * x) , 400), false,false)
_allActors.push(_levelBuilder);
}
//angeled level part
_levelBuilder = new LevelBuilderActor(_background,_levelBuilderAngledBlok ,new Point(390, 350), true,false )
_allActors.push(_levelBuilder);
for (var i:int = 1; i < 3; i++) {//heigh of stack
_levelBuilder = new LevelBuilderActor(_background,_levelBuilderBlokVertical ,new Point(145, 350- (_LevelBoxSpacing * i)), false,true)
_allActors.push(_levelBuilder);
}
}
this is how i creat my bodies
Code:
public function LevelBuilderActor(parent:DisplayObjectContainer,$levelBuilderGraphic:MovieClip ,location:Point,angle:Boolean,Vertical:Boolean)
{
_levelBuilderGrahpic = $levelBuilderGraphic;
///create the hero graphic
parent.addChild(_levelBuilderGrahpic);
//create the hero shapedef
_boxShapeDef = new b2PolygonDef();
if (angle)///angle boolean is true
{///40 in box2d means 80 px in flash
_boxShapeDef.SetAsBox(40 / PhysiVals.RATIO, 10/ PhysiVals.RATIO);
}else {///angle boolean is false
_boxShapeDef.SetAsBox(40 / PhysiVals.RATIO, 40 / PhysiVals.RATIO);
}
_boxShapeDef.density = 0.0;
_boxShapeDef.friction = 0.3;
_boxShapeDef.restitution = 0.2;
////create the bodydef (specify location here)
var boxBodyDef:b2BodyDef = new b2BodyDef();
boxBodyDef.position.Set(location.x / PhysiVals.RATIO, location.y / PhysiVals.RATIO);
if (angle) {///angle boolean is true
boxBodyDef.angle = 35 * Math.PI / 180;
}
///create the body
_boxBody = PhysiVals.world.CreateBody(boxBodyDef);
///create the shape
_boxBody.CreateShape(_boxShapeDef);
_boxBody.SetMassFromShapes();
super (_boxBody,_levelBuilderGrahpic,null);
}
}
{
_levelBuilderGrahpic = $levelBuilderGraphic;
///create the hero graphic
parent.addChild(_levelBuilderGrahpic);
//create the hero shapedef
_boxShapeDef = new b2PolygonDef();
if (angle)///angle boolean is true
{///40 in box2d means 80 px in flash
_boxShapeDef.SetAsBox(40 / PhysiVals.RATIO, 10/ PhysiVals.RATIO);
}else {///angle boolean is false
_boxShapeDef.SetAsBox(40 / PhysiVals.RATIO, 40 / PhysiVals.RATIO);
}
_boxShapeDef.density = 0.0;
_boxShapeDef.friction = 0.3;
_boxShapeDef.restitution = 0.2;
////create the bodydef (specify location here)
var boxBodyDef:b2BodyDef = new b2BodyDef();
boxBodyDef.position.Set(location.x / PhysiVals.RATIO, location.y / PhysiVals.RATIO);
if (angle) {///angle boolean is true
boxBodyDef.angle = 35 * Math.PI / 180;
}
///create the body
_boxBody = PhysiVals.world.CreateBody(boxBodyDef);
///create the shape
_boxBody.CreateShape(_boxShapeDef);
_boxBody.SetMassFromShapes();
super (_boxBody,_levelBuilderGrahpic,null);
}
}