ONeSolid
10-01-2009, 06:24 PM
I am developing a game as a school project but now I have encountered some problems.
The game consists a number of balls, one of them which you control is made so that when it hits another ball in the same color you gain score and the ball disappear. But here is my problem, there should always be "score balls" on the stage. So i added duplicate movieclip to make the scoreball duplicate if the amount of balls gets below 2. The problem starts when i the number goes below 2 a scoreball is added but does not move.
The scoreballs is added like this:
var GreenBall:MovieClip = this.attachMovie("GreenBall", "GreenBall", 110);
numEnemy=3;
GreenBall._x = random(1000);
GreenBall._y = random(800);
GreenBallgravity = 2;
GreenBallbounce = 0.92;
GreenBallspeedx = 0;
GreenBallspeedy = 0;
GreenBallxbounce = 60;
GreenBall._xscale = 50;
GreenBall._yscale = 50;
GreenBall.onEnterFrame = function() {
GreenBallspeedy = GreenBallspeedy+GreenBallgravity;
this._x += GreenBallspeedx/5;
this._y += GreenBallspeedy/5;
if (this._y>floor) {
this._y = floor;
GreenBallspeedy *= -GreenBallbounce;
GreenBallspeedy -= 15;
GreenBallspeedx += 40;
}
if (this._x<left) {
this._x = left;
GreenBallspeedx = +GreenBallxbounce;
}
if (this._x>right) {
this._x = right;
GreenBallspeedx = -GreenBallxbounce;
}
if (this._y<roof) {
this._y = roof;
GreenBallspeedy += GreenBallbounce*5;
}
if (eBall1.pixelHitTest(this) && this._currentframe == 1 && eBall1._currentframe == 1) {
this.gotoAndPlay(2);
numEnemy -= 1;
eBall1.gotoAndStop(random(3));
ArcadeExplosion.start(0,2);
ArcadeExplosion.setVolume(200);
}
if (this._currentframe == 2) {
point += 10;
GreenBallspeedx = 0;
GreenBallspeedy = 0;
GreenBallgravity = 0;
}
};
The duplicate looks like this:
}
for (i=2; i<=numEnemy; i++){
GreenBall.duplicateMovieClip( "GreenBall"+i, i+100);
}
I have a theory, that the ball is not assigned any actionscript when its duplicated because the actionscript goes below the attachMovieclip part.
I am grateful for every answer.
The game consists a number of balls, one of them which you control is made so that when it hits another ball in the same color you gain score and the ball disappear. But here is my problem, there should always be "score balls" on the stage. So i added duplicate movieclip to make the scoreball duplicate if the amount of balls gets below 2. The problem starts when i the number goes below 2 a scoreball is added but does not move.
The scoreballs is added like this:
var GreenBall:MovieClip = this.attachMovie("GreenBall", "GreenBall", 110);
numEnemy=3;
GreenBall._x = random(1000);
GreenBall._y = random(800);
GreenBallgravity = 2;
GreenBallbounce = 0.92;
GreenBallspeedx = 0;
GreenBallspeedy = 0;
GreenBallxbounce = 60;
GreenBall._xscale = 50;
GreenBall._yscale = 50;
GreenBall.onEnterFrame = function() {
GreenBallspeedy = GreenBallspeedy+GreenBallgravity;
this._x += GreenBallspeedx/5;
this._y += GreenBallspeedy/5;
if (this._y>floor) {
this._y = floor;
GreenBallspeedy *= -GreenBallbounce;
GreenBallspeedy -= 15;
GreenBallspeedx += 40;
}
if (this._x<left) {
this._x = left;
GreenBallspeedx = +GreenBallxbounce;
}
if (this._x>right) {
this._x = right;
GreenBallspeedx = -GreenBallxbounce;
}
if (this._y<roof) {
this._y = roof;
GreenBallspeedy += GreenBallbounce*5;
}
if (eBall1.pixelHitTest(this) && this._currentframe == 1 && eBall1._currentframe == 1) {
this.gotoAndPlay(2);
numEnemy -= 1;
eBall1.gotoAndStop(random(3));
ArcadeExplosion.start(0,2);
ArcadeExplosion.setVolume(200);
}
if (this._currentframe == 2) {
point += 10;
GreenBallspeedx = 0;
GreenBallspeedy = 0;
GreenBallgravity = 0;
}
};
The duplicate looks like this:
}
for (i=2; i<=numEnemy; i++){
GreenBall.duplicateMovieClip( "GreenBall"+i, i+100);
}
I have a theory, that the ball is not assigned any actionscript when its duplicated because the actionscript goes below the attachMovieclip part.
I am grateful for every answer.