View Full Version : Enemy problems
zendo49
June 9th, 2006, 12:40 PM
Hey guys
i am creating a mario game and i have been having a little bit of trouble with the goombas(ENEMIES)
you see when i create an enemy i wanted to copy that enemy just so i can use many of the same enemies. But the problem with this is when mario jumps on top of them they do go on die frame, but the movie clip does not remove.
tell me if this would be wrong to remove the movie clip
for(i=1;i<=10;i++) {
_root["goomba"+i].removeMovieClip("goomba2");
}
i have done proper linkage and made sure names were correct.
can someone help me out thanks.
Joppe
June 9th, 2006, 07:28 PM
Uhm what exactly do you want to do? for mario hitting their heads i would use something like this (assuming their reg points are in the bottom)
on marios onEnterFrame function
for(var i = 1;i<10;i++){
tar = _root["goomba"+i]
if(this.hitTest(tar._x,tar._y-tar._height,true)){
removeMovieClip(tar)
}
stoodder
June 10th, 2006, 02:15 AM
Uhm what exactly do you want to do? for mario hitting their heads i would use something like this (assuming their reg points are in the bottom)
on marios onEnterFrame function
ActionScript Code:
</p>
<p>for(var i = 1;i<10;i++){</p>
<p>tar = _root["goomba"+i]</p>
<p>if(this.hitTest(tar._x,tar._y-tar._height,true)){</p>
<p>removeMovieClip(tar)</p>
<p>}</p>
<p>
I actually think this neds ot be the opposite way aorund it shoudl check if the target is being toucched by the mario movie clip more or less
the first thing isuggest is too put an invisible movie clip(3 px X the width of parent movie clip) inside the mario movieclip(to represent his feet) [we'll cal this "feet"] and then at the top of the goombaclip have another invisible box(to represent their heads) [we'll call this "feet"]
Something Like this maybe
//Inside of the _root.goomba.head movieclip
onClipEvent(enterframe)
{
if(this.hitTest(_root.mario.feet))
{
//Run a Certain Action Here(liek destory goomba)
removeMovieClip(_root.goomba)
}
else if(_root.goomba.hitTest(_root.mario)
{
//Run Action To Injure Mario Because he and the goomba collided
}
}
I think that shold work, hopefully lol
this way your not running a loop along with a hitTest therefore increasing efficeny? lol i dunno it just seems better to me. gimme ur input.
ofcourse you would also probobl yhav to change th name of _root.gommba to somehting liek _root.goomba1 or however you want to go about it.
zendo49
June 14th, 2006, 11:42 PM
thanks that works great :-D
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.