Hi, I am trying to add x amount of movieclips to the stage with their own unique _x value. Also with each movie clip added i need to add an array with a smiler name. I tried this code.
under the attachmovie I have ["enemy"+1] but when i trace enemy1 it returns undefined. But when I put ["enemy"+1] it returns the _x value. also if I put _x: i * 5, I only see one movie clip so I have a feeling they all have the same _x and_y value. basically I wanna be able to add 2 enemys to the stage with out over lapping, and the option to add 50 with out too much over lapping (would like to avoid overlapping by also giving various y depths, between 200 and 250)
Thanks now it will add them but obviously in a really stupid order.
I tried to fix things up a bit but there is still a lot of chaos.
I am wondering (this is for my battle system) if my best option would be to find 50 locations (x and y) on the stage that are a bit scattered (my enemies can be far or close, so I would need 50 far enemy locations and 5 close enemy locations so i can have a mix of far and close or all far or all close). I figure I could add all locations to an array so then I can pull up the array slots for each spot. But would this cause loop falures when assigning them, and would it be too much code?
also, I tried using this code but it created a loop crash.
they were spread out but there was a lot that were off the screen and they are close together a lot.
I know 50 is hard to fit thats why I have to have the depth working so the ones with a higher y value are in front, also the farther they are in the back the smaller their height and width will be. any suggestions? or something that could point me in a positive direction?
enemycount = 8; for(i=1; i<enemycount+1; i++){ trace(i); e = random(100); s = random(70); d = 150+s; f = random(500); this["currentenemy"+(i)] = _level0.enemydatabase[0]; this.attachMovie("BrownFox", ["enemy"+i], i, {_x:f+(e/4+25), _y:d}); this["enemy"+i]._width += s/1.5; this["enemy"+i]._height += s/1.5; this["enemy"+i].swapDepths(this["enemy"+i]._y); } for(i=enemycount; i<51; i++){ this["currentenemy"+(i)] = _level0.enemydatabase[1]; }
this is 49 enemys
this is 7 enemys
ANY SUGGESTIONS?
Right now I am making a database of x and y continents and also height and width for depth, and i am adding them to the array in the order i want them to appear on stage. seems to work but its a lot of effort finding the values.
Last edited by brickhouse420; 07-05-2010 at 02:05 PM.
You code is alright but they cluster each other like crazy.
basically i wanna do it all generated with action script. I want to have the first 10 relativity spaced out, then after that it doesn't matter as much as long as it doesn't look like they are being added in rows and columns.
As you see in my script I have them all appear near or above the first line. i'm gonna have to make a code that will also only add them to the area of the bottom line. So there is enemy's you use ranged attacks on at a far and enemy's you have to use close combat attacks.
Last edited by brickhouse420; 07-08-2010 at 12:48 PM.
My idea is to consider a array map (multidimensional array) with _width & _height, and _x & _y with a _y random range for distance. This will maintain a visual distance and for overlapping issue it might/should be _x+someNumber will work