OK so I have a Whole tree (you know where birds like to build nests)
and I have this tree broken into 2 parts the Bottom(wich is gonna hitTest against the character) and the top(which is just a gfx that the player can walk right through(or under))
In the Clips Actions for the Bottom Part I have this
onClipEvent (load) {
function reset(){
this._x=random(550);
this._y=random(200)+100;
enemySpeed=random(4)+1;
}
reset();
}
That randomly Generates a a tree Bottom somewhere on screen as soon as a clip is created(and names them treeBottom1
then in the Actions for the TreeTop I have
onClipEvent (load) {
stringtoparse = String(this)
parsedstring = stringtoparse.split("treeTop")
thisindex = Number(parsedstring[1]);
this._x=_root["treeBottom"+thisindex]._x-42;
this._y=_root["treeBottom"+thisindex]._y-85;
trace("ThisIndex = "+thisindex+" X = "+this._x+" Y = "+this._y)
}
this gets the instance of the treetop being created and tells it to position its self on top of the tree bottom(that matches the instance)
In my control Layer I have this code to generate the trees
numTrees=10;
for (i=2; i<=numTrees; i++){
treeBottom1.duplicateMovieClip( "treeBottom"+i, i+100 );
treeTop1.duplicateMovieClip( "treeTop"+i, i+100 );
trace(i)
}
It Places The tree that is already on the stage(Instance :TreeTop1,TreeBottom1)Randomly perfectly but the second tree it cuts off the bottom corner and all the other 9 trees end up directly on top of the 2nd tree so instead of 10 trees it looks like there are 2 trees
WTF am i doing wrong…please help