Forum Topic: AS2 player movement help

(109 views • 10 replies)

This topic is 1 page long.

<< < > >>
Happy

BabyMaker12

Reply To Post Reply & Quote

Posted at: 7/2/09 09:40 AM

BabyMaker12 NEUTRAL LEVEL 01

Sign-Up: 07/02/09

Posts: 46

hi im trying to get my character to run when you press the A key and stop when you let go. The character running animations plays when you press A but he runs on the spot, when I hold down the A key, the character moves but the animation just stays in one place. As if to say it cant run with the animation playing. Any help to get around this? thanks.

if (Key.isDown(aKey) && facingLeft == true) {
			player.gotoAndPlay("run");
			player._x -= playerxSpeed;
		}

thank you pals.


None

Super-Yombario

Reply To Post Reply & Quote

Posted at: 7/2/09 09:54 AM

Super-Yombario FAB LEVEL 06

Sign-Up: 03/16/07

Posts: 1,156

...
WOW
...

Okay, what is facingLeft supposed to be? Shouldn't pressing A MAKE him face left instead?

if(Key.isDown(65)){

That's all you should have there

RIP Ed McMahon - RIP Farrah Fawcett - RIP Michael Jackson
But wait, there's more...
RIP Billy Mays


Kissing

BabyMaker12

Reply To Post Reply & Quote

Posted at: 7/2/09 09:56 AM

BabyMaker12 NEUTRAL LEVEL 01

Sign-Up: 07/02/09

Posts: 46

no smarty pants theres actually a turn animation, after that animation is done, then facingLeft is true. also aKey is 65. meows.


None

northxiv

Reply To Post Reply & Quote

Posted at: 7/2/09 10:37 AM

northxiv NEUTRAL LEVEL 02

Sign-Up: 06/18/09

Posts: 72

--"The character running animations plays when you press A but he runs on the spot"

--" the character moves but the animation just stays in one place."

ok aren't those two contradicting statements? First you're saying the animation plays yet the character stays in one spot, then a second later you're saying the character moves, but the animation stays still...

By the looks of your code though, I bet you it's that your character is moving on the x axis fine, but the walking animation of him is stuck. This would be because every time your key down code executes, it's telling your movieclip to go to and play at a certain frame. So the animation never actually gets to play because it's going to the first frame of animation each time. (since your key down code is executing like 30 times per second)

It would be like you trying to count from 1 to 10, but 30 times a second I say "start counting" which makes you start counting from 0, so you never even get to 1.


None

Gorilla-Studios

Reply To Post Reply & Quote

Posted at: 7/2/09 10:41 AM

Gorilla-Studios FAB LEVEL 26

Sign-Up: 11/18/05

Posts: 1,698

At 7/2/09 10:37 AM, northxiv wrote: --"The character running animations plays when you press A but he runs on the spot"

you got it spot on, but how do i get around this pal?

Gorilla Studios || A game is like sex, its better when its free

BBS Signature

Happy

Gorilla-Studios

Reply To Post Reply & Quote

Posted at: 7/2/09 10:44 AM

Gorilla-Studios FAB LEVEL 26

Sign-Up: 11/18/05

Posts: 1,698

At 7/2/09 10:41 AM, Gorilla-Studios wrote:
At 7/2/09 10:37 AM, northxiv wrote: --"The character running animations plays when you press A but he runs on the spot"
you got it spot on, but how do i get around this pal?

Sorry forgot to carry on with that. Good answer northxiv, but I guess you need to know an answer babymaker12. Personally I'd use a key listener, I'm not going to give you a block of code so you can just copy and paste it. Theres a tutorial in the AS Main,
here.

Gorilla Studios || A game is like sex, its better when its free

BBS Signature

Crying

BabyMaker12

Reply To Post Reply & Quote

Posted at: 7/2/09 10:51 AM

BabyMaker12 NEUTRAL LEVEL 01

Sign-Up: 07/02/09

Posts: 46

I dont understand listeners cant u just help me with that peice of code?? i dont want to rearrange all of my code. im sure it can be done this way.


None

northxiv

Reply To Post Reply & Quote

Posted at: 7/2/09 11:06 AM

northxiv NEUTRAL LEVEL 02

Sign-Up: 06/18/09

Posts: 72

Buddy, we are trying to help you, but you have to show a little bit of effort on your part or else I bet some people on here are going to think you're just wanting an easy fix or some code you can copy and paste. If you don't understand listeners, learn them. Try to problem-solve this.. your gotoAndPlay statement is executing continuously, so how do you get it to only execute once after you press the a key?


None

northxiv

Reply To Post Reply & Quote

Posted at: 7/2/09 11:12 AM

northxiv NEUTRAL LEVEL 02

Sign-Up: 06/18/09

Posts: 72

Judging by your comments in this topic http://www.newgrounds.com/bbs/topic/1077 398 towards another user and the fact that you're spamming this thread in it trying to find people to answer your question, I don't think anyone is going to help you out any more. You are not a person worth helping.


None

Draglino

Reply To Post Reply & Quote

Posted at: 7/2/09 12:38 PM

Draglino DARK LEVEL 03

Sign-Up: 11/07/07

Posts: 45

At 7/2/09 09:40 AM, BabyMaker12 wrote: hi im trying to get my character to run when you press the A key and stop when you let go. The character running animations plays when you press A but he runs on the spot, when I hold down the A key, the character moves but the animation just stays in one place. As if to say it cant run with the animation playing. Any help to get around this? thanks.

if (Key.isDown(aKey) && facingLeft == true) {
player.gotoAndPlay("run");
player._x -= playerxSpeed;
}

thank you pals.

Isnt it supposed to be faceleft after pressing button... I learned this way all the time. When you press the button, you make character which way it turns by variables. if aKey is down, you make facingLeft == true, but if you press D in keyboard, youmake it facingRight isnt it ? What happens if facingLeft is False and player is trying to press aKey ?? Theres the real question, what makes facingLeft == true ?? if you make like

:if(Key.isDown(aKey)){
:facingLeft == true;
:}

That style of coding looks like you are doing AS3...


None

Woadraiders

Reply To Post Reply & Quote

Posted at: 7/2/09 12:43 PM

Woadraiders DARK LEVEL 11

Sign-Up: 11/11/07

Posts: 561

No it's definitely AS2 because in AS3 the movieclips have a x property, but in AS2 its _x .

And babymaker, do a tutorial.

Mibbygames.com
panterA

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 01:40 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!