View Full Version : Troubleshooting.
kerek
April 5th, 2005, 12:57 AM
FLA: http://www.matthewcorway.com/crap/retailblundersgame.fla
SWF: http://www.matthewcorway.com/crap/retailgame.html
Can someone help me figure out why when press crouch (DOWN KEY) and attack (SPACE) multiple times, the hero freezes?
I want my crouched attack to be the same as when he is standing, you tap SPACE to attack and you can as many times as you want.
Controls for my game are the arrow keys to move, space to attack, down key to crouch. While crouched you press space again to attack crouched.
If you attack more than once while crouched, the hero freezes and I don't seem to see a problem but maybe a fresh pair of eyes is what I need.
Thanks
kerek
April 5th, 2005, 01:11 AM
Here is the code that is on my hero MC, so you don't have to download the FLA.
onClipEvent(load){
this.stop();
_root.chardir = "right";
_root.crouching = false;
_root.crouched = false;
}
onClipEvent(enterFrame){
if (!_root.attacking){
if (Key.isDown(Key.LEFT)) {
this.gotoAndStop("leftrun");
this._x -= 3;
_root.chardir = "left";
} else if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop("rightrun");
this._x += 3;
_root.chardir = "right";
} else if (Key.isDown(Key.DOWN)) {
if (!_root.crouched){
if (_root.chardir == "left"){
this.gotoAndStop("crouchleft");
_root.crouching = true;
} else if (_root.chardir == "right"){
this.gotoAndStop("crouchright");
_root.crouching = true;
}
}
}
}
if (!_root.crouching){
if (Key.isDown(Key.SPACE)) {
if (_root.chardir == "left"){
this.gotoAndPlay("leftattack");
_root.attacking = true;
} else if (_root.chardir == "right"){
this.gotoAndPlay("rightattack");
_root.attacking = true;
}
}
} else if (_root.crouching){
if ((Key.isDown(Key.SPACE)) && (Key.isDown(Key.DOWN))){
_root.crouched = true;
_root.attacking = true;
if (_root.chardir == "left"){
this.gotoAndStop("crouchleftattack");
} else if (_root.chardir == "right"){
this.gotoAndStop("crouchrightattack");
}
}
}
}
onClipEvent(keyUp){
if (!_root.attacking){
if (Key.getCode() == Key.RIGHT) {
this.gotoAndStop("rightidle");
}
if (Key.getCode() == Key.LEFT) {
this.gotoAndStop("leftidle");
}
if (Key.getCode() == Key.SPACE) {
_root.attacking = false;
}
if (Key.getCode() == Key.DOWN) {
if (_root.chardir == "left"){
this.gotoAndStop("crouchleftup");
_root.crouching = false;
_root.crouched = false;
} else if (_root.chardir == "right"){
this.gotoAndStop("crouchrightup");
_root.crouching = false;
_root.crouched = false;
}
}
}
}
Blackspirit
April 5th, 2005, 03:39 AM
ok, I put some dynamic text boxes on the stage with the variables attacking, crouching and crouched.
This makes it fairly easy to debug, because doing a trace in an onenterframe just ends up looking terrible.
They didn't seem to show the right values at the right time. I was totally standing and crouching and crouched were true....
I took out the line in your keyup, if (!_root.attacking){
It seems to work better now, but when crouched, the attack still doesn't work after the first time.
Although, the attacking variable is toggling from false to true, so you have an animation problem there, where its trying to play an animation because your holding the down key, and it won't play the attacking animation at the same time.
Ah, yes. When you crouch variables are:
Crouching : true
Crouched : false
Attacking : false
Shouldn't crouched be true?
Then you press space and:
Crouching : true
Crouched : true
Attacking : true
Stop your attack
Crouching : true
Crouched : true
Attacking : false
Try to attack again, and it doesn't work
So, the crouched variable seems to stop you attacking if its true.
:)
kerek
April 5th, 2005, 10:16 AM
Well the way I want it is crouched is the variable that is in the crouched attack so it won't play the other DOWN arrow state in the first area. If I take out crouched, then after every attack he crouches down again. Once I put the crouched in, it stopped that but after every attack he stops completely.
What should I do to ensure that when I press space while crouched, that he will attack and multiple times if they want him too.
nathan99
April 5th, 2005, 10:37 AM
have you tried using multiple if statements instead?
i dont no if itll work but in theory it does
kerek
April 5th, 2005, 08:31 PM
When I take out the _root.attacking = true; in the if (crouching) statement then it works with 1 hit only.
What I mean is, you can do 1 crouch attack and still get back up and crouch and do another while as before if you did more than 1, it would freeze the character (because it set attacking as true and most of the movement works off of attacking as false.)
So can anyone help me anymore? What should I do to get multiple crouch attacks in the same crouch functional?
nathan99
April 5th, 2005, 10:17 PM
Do you mean like this?
kerek
April 5th, 2005, 11:01 PM
No, I had mine like that a while back but it's ALMOST what I want. What I want is to only attack once at a time, but if they press space multiple times then they can attack more than once.
One press of SPACE = One attack
Two taps of SPACE = One attack followed by another.
Of course if they just mash on space he will only attack until they stop pressing it. (no buffer)
Do you get what I mean? It's almost to the point of what I want, but I want it to be exactly like the standing attack. Where you press space, it attacks once. You press it again and you can attack again without re-crouching.
Actually nathan99, if you could post the changes you made I believe I can fix it to be exactly how I want it to be. Please post the changes that I should do to my code and I will test out how it works. Thanks man.
nathan99
April 5th, 2005, 11:51 PM
all that i have that i can remember done is got rid of the stop, but i may have done more and cant post the fla......too big
kerek
April 6th, 2005, 01:09 AM
Ohh ok. Well I don't want him to attack like that. Just a single swipe of the sword per SPACE button pressed.
Thanks anyways.
nathan99
April 6th, 2005, 01:59 AM
yer the problem is with your stop, you are going to have to think of another way around that
kerek
April 6th, 2005, 05:02 PM
I still havent been able to remedy this. Can anyone take a look?
kerek
April 15th, 2005, 09:56 AM
-bump=
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.