actionscript 3 - AS3 How to spawn movieclips onto the stage randomly between two points? -
my game birds-eye view car game stear car left , right avoid other cars. thing don't know how make ai cars spawn automatically on road. because map has grass on left , right hand side , road in middle , want ai cars spawn on road therefore between 2 x points. appreciated, many thanks.
i have code:
var mc:red_car = new red_car(); addchild(mc);
var randomx:number = math.random() * 750 mc.x = randomx;
which spawns object on stage can't spawns between 2 specfic points.
position movieclip before add screen. use y position car needs positioned in road , generate random x between 0 , screen width. add car stage.
var car:movieclip = new red_car(); car.y = //your y position here car.x = math.random () * 750; addchild(car);
Comments
Post a Comment