Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem removing 1 of 8 generated collisions

Status
Not open for further replies.

Marleyuk

Technical User
Feb 10, 2006
25
GB
Hello, im a bit of a flash amature but im having ago at creating a small game, the graphics are pretty awful but it seems to work. The problem im having is I use the following

Code:
numEnemy=8; for (i=2; i<=numEnemy; i++){ enemy1.duplicateMovieClip( "enemy"+i, i+100 ); } score=0;

To duplicate the enemy 8 times, 7 of them can be shot and removed but 1 wont disappear. I think i may have to remove the original enemy but im not sure where. Can anyone help please.



Thanks,
Marls.

This post has been edited b
 
My health box text box is a movie clip with the instance name hpBar, currently it shows the value as blank. I need to make it so instead of the results being printed as a trace they are printed in the textbox.
 
Code:
var hpAmount = 100;
var numEnemy = 8;
for (i=1; i<=numEnemy; i++) {
    mcEnemy = this.attachMovie("enemy", "enemy"+i, 100+i);
    reset(mcEnemy);
    mcEnemy.onEnterFrame = moveEnemy;
}
function reset(mc:MovieClip):Void {
    mc._x = 300;
    mc._y = Math.floor((Math.random()*200+100));
    mc.enemySpeed = Math.floor(Math.random()*4+1);
}
function moveEnemy():Void {
    if (tank_mc.scrollStart) {
        this._x -= this.enemySpeed+mainGround.groundSpeed;
    } else {
        this._x -= this.enemySpeed;
    }
    if (this._x<-10) {
        reset(this);
    }
	
if (this.hitTest(tank_mc)) {
    hpAmount--;
    hpBar.yourTextFieldInstance.text = hpAmount;
        
    }
}

[code]

The Hp box remains blank. and so does the score actually.
 
Code:
//set health points
var hpAmount = 100;
//set amount of generated enemies
var numEnemy = 8;
for (i=1; i<=numEnemy; i++) {
    mcEnemy = this.attachMovie("enemy", "enemy"+i, 100+i);
    reset(mcEnemy);
    mcEnemy.onEnterFrame = moveEnemy;
}
function reset(mc:MovieClip):Void {
    mc._x = 300;
    mc._y = Math.floor((Math.random()*200+100));
    mc.enemySpeed = Math.floor(Math.random()*4+1);
}
function moveEnemy():Void {
    if (tank_mc.scrollStart) {
        this._x -= this.enemySpeed+mainGround.groundSpeed;
    } else {
        this._x -= this.enemySpeed;
    }
    if (this._x<-10) {
        reset(this);
    }

//health point hit test

if (this.hitTest(tank_mc)) {
    hpAmount--;
    hpBar.hpbar.text = hpAmount;
        
    }
}

hp bar is the text field instance name and still nothing appears.
 
Still the same results. Could i be something else ive messed up?
 
Its direct on the stage, in my background scene.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top