AS3: limit objects to stage width?
Posted
by
Gabriel Meono
on Game Development
See other posts from Game Development
or by Gabriel Meono
Published on 2011-11-27T18:44:58Z
Indexed on
2011/11/28
2:04 UTC
Read the original article
Hit count: 600
actionscript-3
|box2d
I want to limit the creation of objects acording to the stage width.
My method is the following:
for (var i:int = 0; i<7; i++){
If I put something like this, it won't work
for (var i:int = 0; i<(stage.width); i++){
What I'm doing wrong?
Full code:
[SWF(width = 350, height = 600, frameRate = 60)]
import com.actionsnippet.qbox.*;
var sim:QuickBox2D = new QuickBox2D(this);
sim.createStageWalls();
// make a heavy circle
sim.addCircle({x:3, y:3, radius:0.4, density:1});
// create a few platforms
// make 26 dominoes
for (var i:int = 0; i<7; i++){
//End
sim.addCircle({x:1 + i * 1.5, y:18, radius:0.1, density:0});
sim.addCircle({x:2 + i * 1.5, y:17, radius:0.1, density:0});
sim.addCircle({x:1 + i * 1.5, y:16, radius:0.1, density:0});
sim.addCircle({x:2 + i * 1.5, y:15, radius:0.1, density:0});
//Mid end
sim.addCircle({x:0 + i * 2, y:14, radius:0.1, density:0});
sim.addCircle({x:0 + i * 2, y:13, radius:0.1, density:0});
sim.addCircle({x:0 + i * 2, y:12, radius:0.1, density:0});
sim.addCircle({x:0 + i * 2, y:11, radius:0.1, density:0});
sim.addCircle({x:0 + i * 2, y:10, radius:0.1, density:0});
}
sim.start();
sim.mouseDrag();
© Game Development or respective owner