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

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -