Temporary Invisibility
- ChrisCookie
-
ChrisCookie
- Member since: Aug. 18, 2010
- Offline.
-
- Forum Stats
- Member
- Level 07
- Blank Slate
Hello everyone, I'm currently working on a game, and I'm having troubles with something.
Basically, what I'm trying to do is make it so that once you get hit by a hazard/enemy, there's a few seconds of invincibility before you can get hurt again.
I'm using AS2, and the code I'm using for the hazard is this:
onClipEvent(enterFrame) {
if(_root.char.hitTest(this)) {
_root.vcam.hp.nextFrame();
}
}
I've tried a few different methods, but none of them have worked.
Any ideas?
All help is appreciated.
- AntiAliasProductionz
-
AntiAliasProductionz
- Member since: Apr. 20, 2008
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
At 9/15/10 07:42 PM, ChrisCookie wrote: Hello everyone, I'm currently working on a game, and I'm having troubles with something.
Basically, what I'm trying to do is make it so that once you get hit by a hazard/enemy, there's a few seconds of invincibility before you can get hurt again.
I'm using AS2, and the code I'm using for the hazard is this:
onClipEvent(enterFrame) {
if(_root.char.hitTest(this)) {
_root.vcam.hp.nextFrame();
}
}
I've tried a few different methods, but none of them have worked.
Any ideas?
All help is appreciated.
If you post the source code, I can write you a little script to put into it with instructions.
I'll need the source though.
- ChrisCookie
-
ChrisCookie
- Member since: Aug. 18, 2010
- Offline.
-
- Forum Stats
- Member
- Level 07
- Blank Slate
At 9/15/10 10:02 PM, AntiAliasProductionz wrote:
If you post the source code, I can write you a little script to put into it with instructions.
I'll need the source though.
Sorry, not really sure which code the source code is exactly.
- the1manwiththeplan
-
the1manwiththeplan
- Member since: Jun. 10, 2008
- Offline.
-
- Forum Stats
- Member
- Level 17
- Blank Slate
if ( invisibility = ="true" ) { //Do nothing
} else {//actions for decreasing health variable here
}
...
- the1manwiththeplan
-
the1manwiththeplan
- Member since: Jun. 10, 2008
- Offline.
-
- Forum Stats
- Member
- Level 17
- Blank Slate
Woops invincibility I meant wrong super power my bad lol
...
- ChrisCookie
-
ChrisCookie
- Member since: Aug. 18, 2010
- Offline.
-
- Forum Stats
- Member
- Level 07
- Blank Slate
Okay, I see, but I'm still not sure how I would make that work.
By that I mean, how would I make an invincibility time, and then how would it work?
- the1manwiththeplan
-
the1manwiththeplan
- Member since: Jun. 10, 2008
- Offline.
-
- Forum Stats
- Member
- Level 17
- Blank Slate
At 9/16/10 02:25 AM, ChrisCookie wrote: Okay, I see, but I'm still not sure how I would make that work.
By that I mean, how would I make an invincibility time, and then how would it work?
if (invincible == true) {
invincibleTimer++;
if (invincibleTimer>=amount_of_frames_you_can_turn_invincible_for) {
invincible = false;
invincibleTimer = 0;
} else {//actions for decreasing health variable here
}
} ...
- BasV
-
BasV
- Member since: May. 7, 2005
- Offline.
-
- Forum Stats
- Member
- Level 23
- Game Developer
At 9/16/10 07:00 AM, the1manwiththeplan wrote: if (invincible == true) {
No need for double boolean checks:
if (invincible ) {
//etc
}
same effect, less calculation
- ChrisCookie
-
ChrisCookie
- Member since: Aug. 18, 2010
- Offline.
-
- Forum Stats
- Member
- Level 07
- Blank Slate
Thanks you guys, but it isnt working. :\
I'm not too great at AS, so I'm not really sure what to do with that code to be honest.
Am I supposed to do anything else BESIDES that code?
How does Flash know what "Invincible" means and exactly how I want to use it?
I know they probably seem like stupid questions, but I can't get it to work unless I know the answers.
- the1manwiththeplan
-
the1manwiththeplan
- Member since: Jun. 10, 2008
- Offline.
-
- Forum Stats
- Member
- Level 17
- Blank Slate
At 9/17/10 12:52 AM, ChrisCookie wrote: Thanks you guys, but it isnt working. :\
I'm not too great at AS, so I'm not really sure what to do with that code to be honest.
Am I supposed to do anything else BESIDES that code?
How does Flash know what "Invincible" means and exactly how I want to use it?
I know they probably seem like stupid questions, but I can't get it to work unless I know the answers.
No Flash doesn't know what invincibility is
No you need more than just that code you need to declare the boolean variable as well
By the sounds of it your not ready to be tackling stuff like this anyway I dont think your grasping it at all or even how it works...
...
- ChrisCookie
-
ChrisCookie
- Member since: Aug. 18, 2010
- Offline.
-
- Forum Stats
- Member
- Level 07
- Blank Slate
Well, I don't really think it's up to you to decide who gets to make stuff and who doesn't.
If you're not going to be helpful, don't post please.
- Left4DeathInFire
-
Left4DeathInFire
- Member since: May. 27, 2010
- Offline.
-
- Forum Stats
- Member
- Level 09
- Blank Slate
At 9/17/10 08:34 PM, ChrisCookie wrote: Well, I don't really think it's up to you to decide who gets to make stuff and who doesn't.
If you're not going to be helpful, don't post please.
I know I have no business with this but, He may actually be right but, in any case I am going to try and explain it better.
First of all, You do need to declare 2 variables for the1man's code: Invincible and InvicibleTimer such as:
var Invincible = false // or declare as a Boolean.
var InvincibleTimer = 0;
Now, at the top of your character add the1man's code.
It basically says; If Invincible is true, add more to the timer, If the timer equals specified time, then end invicibility and go back to normal health decrease. You may want to add like a effect to show that you are invincible, like have a green circle follow that player.
Left4DeathInFire//--//Master of Noobs
- Moonasha
-
Moonasha
- Member since: Mar. 29, 2004
- Offline.
-
- Forum Stats
- Member
- Level 15
- Blank Slate
At 9/15/10 07:42 PM, ChrisCookie wrote: Hello everyone, I'm currently working on a game, and I'm having troubles with something.
Basically, what I'm trying to do is make it so that once you get hit by a hazard/enemy, there's a few seconds of invincibility before you can get hurt again.
I'm using AS2, and the code I'm using for the hazard is this:
onClipEvent(enterFrame) {
if(_root.char.hitTest(this)) {
_root.vcam.hp.nextFrame();
}
}
I've tried a few different methods, but none of them have worked.
Any ideas?
All help is appreciated.
Ditch AS2 and write your code in AS3 classes. Then you can do a simple conditional based on a var in your hero class...
[code]If (invuln == false)
{
damage(input);
}[/code]

