View Full Version : invincible while hiding
Fayte
February 19th, 2005, 11:55 PM
i have a problem here ...
the hero hides with <down> key and attacks with <up> key but how do i script it such that the hero doesnt receive hits from the enemy while hiding?
heres the .fla
http://www.geocities.com/cloudstrife_infini/TrueEnemy.fla
any help would be appreciated, thanks!
superNoobice
February 20th, 2005, 12:49 AM
1 way i think of is to separate the animation for hiding and the mc for hiding state and also remove the hitTest of the hiding state so that he would be invincible.
frost_oni
February 20th, 2005, 01:12 AM
easier would be so set a boolean variable to false. for example:
on(press){
//gotandstop to the 'down' state;
hitMe = false;
}
and your code which allows the player to be hit should be enclosed within this:
if(hitMe == true){
//do hit collisions
}
i did that with the game i am developping. tell me whether it works.
Fayte
February 20th, 2005, 04:41 AM
just to clarify things, i put
on(keyPress "<Down>"){
_root.heroguy.gotoAndStop("hide");
hitMe = false;
}
on(keyPress "<Up>"){
_root.heroguy.gotoAndStop("attack");
hitMe = true;
}
on a button outside the stage to control the character, and on the attacker, i put
onClipEvent(enterFrame) {
if(hitMe == true) {
tellTarget ("_parent.heroguy") {
gotoAndPlay ("hit");
}
}
}
is that how boolean variables work?
alzor
February 23rd, 2005, 08:16 PM
onClipEvent (load){
invincible=0;
}
onClipEvent (enterFrame){
if (Key.isDown(Key.(whatever)){
invincible=1;
}else if (!Key.isDown(Key.(whatever)){
invincible=0;
}
if (invincible==1){
//your invincibility code
}else if (invincible=0){
//your hittest code
}
}
that should do the trick, if not somebody better than me will give you a better answer.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.