Skip to main content
gamedev.net
🔒 Locked

Need help with AS code issues

Started by BrioCyrain Dec 12, 2008 at 8:35 PM 4 replies 650+ views
Original Post
BrioCyrain
BrioCyrain
Okay I am like having issues with a fighting game tutorial(Flash/ActionScript) and here is the code I am having trouble with: _____________________________________________________ rick_mc.step=15; rick_mc.attack = false; rick_mc.stance= 1; rick_mc.crouch=false; this.onEnterFrame = function() { if(rick_mc.attack==false) { if (Key.isDown (Key.RIGHT) ) { rick_mc._xscale = 100; rick_mc.stance=1; rick_mc._x+=rick_mc.step; rick_mc.gotoAndStop("walk"); } else if (Key.isDown (Key.LEFT) ) { rick_mc._xscale = -100; rick_mc.stance=0; rick_mc._x-=rick_mc.step; rick_mc.gotoAndStop("walk"); } else if (Key.isDown (Key.DOWN) ) { rick_mc.gotoAndStop("crouch"); rick_mc.crouch=true; } else if (!Key.isDown () ) { rick_mc.gotoAndStop("stance"); rick_mc.crouch=false; } } } ___________________________________________________ My character is moving but isn't actually Walking. I named the walking animation "Walking" and the walking frame label "walk" and he is stuck on one of the walking frames and not actually performing the actual Walking animation. Also he is not doing the crouching animation either. Help please! [Edited by - BrioCyrain on December 13, 2008 7:26:39 AM]
Puck
Puck
I'm no Flash guru, but I do believe you want "gotoAndPlay("walk")". As for crouching, did you verify that you have a frame labeled "crouch"?
BrioCyrain
BrioCyrain
I used your advice and instead of being stuck on one of the walking frames...it's stuck on one of the walking frames AND when I stop "walking" he does the downkick animation....wierd.
dashurc
dashurc
I have worked with ActionScript in the past, but it's been a while, so forgive me if I'm wrong, but I think using the onKeyDown and onKeyUp callback functions (movieclip functions) are better for this as they will return you which key was pressed.

The isDown will always be true as long as the button is held, meaning it will trigger the code to enter the walking state.

I'd prefer to trigger the walking state once when onKeyDown is called with the left or right key, and return to stance if onKeyUp is called with the same button.

While you're in the walking state the onEnterFrame is where you'll do your characters actual moving (not the animation, just the adjustment of the movieclip position).

For example:
if(isWalking)
{
character._x += walkDelta;
}
dashurc
dashurc
oh, and check out the actionscript dictionary if you don't already use it:

http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.