|
-
My Rock Array Problem,
Basically have no idea What i am doing, I am trying to create a game where the player has to dodge rocks and if he doesn't and the rock collides with him an animation will play for the rock to be destroyed, the player to lose a bit of life and more rocks to come, but this is my problem the rock comes on in, my player hits, but straight away it destroys and the rock no longer comes from the side, i had feeling it was because the whole array was deleted with removeMovieClip(); so i i have no idea, take a look at the code :
Code:
onEnterFrame = function()
{
if (playerLife<0)
{
gotoAndStop(3);
}
}
for (i=0; i<numberRock; i++)
{
newRock = attachMovie("Enemy", "Enemy"+i, i);
newRock._y = Math.random()*Stage.height;
newRock.rockSpeed += .5;
newRock.onEnterFrame = function()
{
if(this._x>Stage.width)
{
this._y = Math.random()*Stage.height;
this._x = 20;
rockSpeed += .5;
}
this._x += rockSpeed;
if(this.hitTest(_root.Player))
{
playerLife -= 2;
newRock.play();
score += 100;
this.removeMovieClip();
}
else
{
// to add
}
}
}
stop();
any idea's ? because i have run out of them, if think its literally because of the array itself but i don't know.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|