PDA

View Full Version : shoot continously



rahul_7star
August 5th, 2008, 07:42 AM
How to duplicate movie and make them fall from top( _x is same for all)

Favardin
August 5th, 2008, 01:02 PM
That is not even a question.

rahul_7star
August 5th, 2008, 01:31 PM
That is not even a question.

ok

Space ship is there at the top...and that space ship is continously dropping bombs .

Krabex
August 5th, 2008, 08:11 PM
ok

Space ship is there at the top...and that space ship is continously dropping bombs .

Simply have a function called 'dropBomb' that looks somthing like this...


function dropBomb ():Void
{
var bomb:MovieClip = this.attachMovie ("bomb", "bomb" + i, this.getNextHighestDepth());
bomb._x = spaceShip._x;
bomb._y = spaceShip._y;
bomb.onEnterFrame = function ():Void
{
this._y += 5;
if (this._y > Stage.height)
{
this.removeMovieClip();
}
}
}Pretty straight forward, the function simpy attaches a new bomb, positions it where the spaceship is and tells it to fall 5 pixels a frame, when it reaches the bottom it is removed. Now all you do is call this with an interval...



var myInterval:Number = setInterval (this,"dropBomb", 2000);
If your confused about it just check help files :beer2:

rahul_7star
August 7th, 2008, 04:08 AM
thanks ..but "bomb" + i is undefined ...so how will do the collsion..with these falling bomb..

Simply have a function called 'dropBomb' that looks somthing like this...


function dropBomb ():Void
{
var bomb:MovieClip = this.attachMovie ("bomb", "bomb" + i, this.getNextHighestDepth());
bomb._x = spaceShip._x;
bomb._y = spaceShip._y;
bomb.onEnterFrame = function ():Void
{
this._y += 5;
if (this._y > Stage.height)
{
this.removeMovieClip();
}
}
}Pretty straight forward, the function simpy attaches a new bomb, positions it where the spaceship is and tells it to fall 5 pixels a frame, when it reaches the bottom it is removed. Now all you do is call this with an interval...



var myInterval:Number = setInterval (this,"dropBomb", 2000);
If your confused about it just check help files :beer2:

dhiraj318
August 7th, 2008, 07:50 AM
Hi Check this might help ....

rahul_7star
August 7th, 2008, 01:18 PM
Hi Check this might help ....
well is there any difference........well implementd diff logic...but "bombiundefined" will work definately .

TCAtect
August 7th, 2008, 02:23 PM
well is there any difference........well implementd diff logic...but "bombiundefined" will work definately .

So has it been solved? I find it very difficult to understand what you're saying. "bombiundefined"?

rahul_7star
August 8th, 2008, 01:22 AM
So has it been solved? I find it very difficult to understand what you're saying. "bombiundefined"?

Hi will if you inc the value of i then each time you will have diff name like bobm1 bomb2 etc...
but if you want same name for each movie clip then you can use "_root.bobmundefined" also
like
var q:MovieClip=this.attachMovie("sg","sg"+h,this.getNextHighestDepth())

here q will have _root.sgundefined untill h is intailized to some value.

so you can use _root.sgundefined also as a movie clip for collsion or anythng

SparK_BR
August 16th, 2008, 11:40 PM
you don't need the same name

every time you create a bomb add it to an array
to make the hitTest you would go through something like



var limit = array.length;
for(var i=0; i<limit; i++){
if(player.hitTest(array[i])){
array[i].explode(); //do the explosion stuff
}
}
i'm noob, so don't listen that much to me...