Hi there,
I have been doing a game scene where MC(target) will fall from the top to the bottom of the screen. I want to make these targets to be shot, each one will fall down as a loop until in a time I want then another target will fall down ...may be like 1 minute each.
It's ok with only 1 MC but, I wan to add others to the scene. I'm using for statement to add MC and that make a function for it to ru....likt this....
I have tried many ways to create another mc such asCode:for(i=1;i<=numTarget;i++){ tar=_root.attachMovie("mcTarget","t"+i,i); tar._x=random(Stage.width); tar._y=-random(Stage.height); tar._xscale=random(50)+50; tar._yscale=tar._xscale; tar.onEnterFrame=targetRun; } function targetRun(){ if(_root.tarTimetxt>=0){ this._y+=spdTarget*(this._xscale/100); if(this._y>Stage.height){ this._x=random(Stage.width); this._y=-this._height; } } if(_root.tarTimetxt>=10){ for(i=1;i<=numTarget;i++){ delete _root["t"+i].onEnterFrame; _root["t"+i].removeMovieClip(); } } }
I created a new scene so everything will be like fresh start but, still didn't work very well.
I created another FOR in the same frame and add another function, used all different variables. a,b,c,d,....
So the questions are..
1)this for statement can be more than one in the same frame? or I can only use one, if YES then how can I add another MC to the scene.
2) Is there any better ways else to create thing like I want just MC which is a target to shoot fall down in a time I want ?
OH! the shooting code I use is like this...
3) Do I have to created function sm/thg like ballRun every MC I change?Code:function ballRun(){ this._x+=this.spdX; this._y+=this.spdY; for(i=1;i<=numTarget;i++){ tar=_root["t"+i]; if(this.hitTest(tar)){ if(tar._currentframe==1){ tar.play(); this.removeMovieClip(); } } } }
Thanks in Advance.


Reply With Quote
