Results 1 to 5 of 5
Thread: hitTest on duplicated MovieClips
-
April 30th, 2012, 07:34 PM #13Registered User
postshitTest on duplicated MovieClips
In my as2 game i have an enemy on stage called "Enemy0", my script duplicates this enemys' actions and spawns a var number of enemies called "Enemy". However when i play the game my "Enemy0" hits the wall I made while my "Enemy" ignores the hitTest and goes through it.
How do i make it so that my "Enemy0" and my duplicated enemy, "Enemy", hit the wall? I can upload my flash or show my code if need be.
Plz help and thanks in advance for any help.Last edited by Acon; May 1st, 2012 at 11:47 AM.
-
May 2nd, 2012, 12:35 PM #23Registered User
postsPlz help me.
this problem is driving me insane
-
May 3rd, 2012, 03:39 PM #3
you need to post your code
you have a scope issue
-
May 8th, 2012, 11:52 AM #43Registered User
poststhe following code is to copy my "enemy0";
var nrEnemies = 2;
for(i=1; i<nrEnemies; i++)
{
_root.Enemy0.duplicateMovieClip("Enemy" +i, _root.getNextHighestDepth());
}
the following is my code for my "enemy0"
onClipEvent(load)
{
function reset()
{
var timer = 12;
this._y = Math.random() * 300
this._x = 1000
mySpeed = Math.ceil(Math.random() * 6) + 6;
}
reset();
}
onClipEvent(enterFrame)
{
//in every frame the enemy move left in the speed defined in the reset function.
this._x -= mySpeed;
if (this._x < -10)
{
//if the enemy is not on the screen, we reset it.
reset();
}
//if our timer is bigger than 12 we get a new
if (timer >= 12)
{
//direction to the Ship.
var dir = Math.ceil(Math.random() * 2)
//We get a random number, 1 or 2. 1 is up, 2 is down.
//Then we set timer to 0, so we only get a new dir when timer is bigger than 12
timer = 0;
}
if (dir == 1)
{
//if dir = 1, we move the ship up.
this._y -= 3;
} else if(dir == 2)
{
//if dir = 2, we move the ship down.
this._y += 3;
}
//increase timer by 1, so the timer gets equal to 12 and we get a new direction.
timer++
}
onClipEvent(enterFrame)
{
if (_root.lives <= 0)
{
this.removeMovieClip();
}
}
and the following is the code for my wall
onClipEvent(enterFrame)
{
if(this.hitTest(_root.Ship))
{
_root.Ship._y += 10;
}
}
onClipEvent(enterFrame)
{
if(this.hitTest(_root.Enemy0))
{
_root.Enemy0._y += 10;
}
}
-
May 8th, 2012, 03:42 PM #51Registered User
postsHi..
need some help in flash
in as2
i want to play movie clips as per the time
ex .
1mc = 9.00 to 11.00
2mc = 12.00 to 16.00
and so..
plzzzzz
i hav written some code this not working prpoerly
some help would be gr8 for me thks

Reply With Quote

Bookmarks