ForumsProgramming ForumI'm Such an idiot, probably the easiest help you could give a noob

18 6027
Dannydaninja
offline
Dannydaninja
948 posts
Nomad

ACTIONSCRIPT 2.0 :
I know that for movement with the UP DOWN LEFT RIGHT Keys i use:
-----

onClipEvent (load) {
power = 3;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_x -= power;
}
if (Key.isDown(Key.RIGHT)) {
_x += power;
}
if (Key.isDown(Key.UP)) {
_y -= power;
}
if (Key.isDown(Key.DOWN)) {
_y += power;
}
}

-----

But what about the WASD Keys for 2 Player? I tryed:

----

onClipEvent (load) {
power = 3;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.A)) {
_x -= power;
}
if (Key.isDown(Key.D)) {
_x += power;
}
if (Key.isDown(Key.W)) {
_y -= power;
}
if (Key.isDown(Key.S)) {
_y += power;
}
}

----

So what's the code for movement with the WASD keys...?

  • 18 Replies
Dannydaninja
offline
Dannydaninja
948 posts
Nomad

none of the codes in there helped... Please someone.

Darkroot
offline
Darkroot
2,763 posts
Peasant

onClipEvent (enterFrame) {
if(Key.isDown(65)){
trace("A is down"
}
}

You could combine A and Left key with the || operator to make the code nicer.

Darkroot
offline
Darkroot
2,763 posts
Peasant

Which would look like this

onClipEvent (enterFrame) {
if(Key.isDown(65) || Key.isDown(Key.LEFT)){
trace("A is down"
}
}

Dannydaninja
offline
Dannydaninja
948 posts
Nomad

Did not work.

plasmafish
offline
plasmafish
252 posts
Nomad

if (Key.isDown(Key.LEFT)||Key.isDown(65)){
CODE;
}

This above method is what I used for moving my character. Using darkroots way looks the same to me as long as you substitute the trace command for your supporting code that moves the character left. And you would have to repeat using the correct keycodes for each direction and number.

Darkroot
offline
Darkroot
2,763 posts
Peasant

Dannydaninja it does work because I tried it. Your not trying hard enough people aren't going to do everything for you. Try putting it in the movieclip.

PixelSmash
offline
PixelSmash
566 posts
Nomad

Do things trace at all in those functions? Because if they don't, you might have made some mistake...

Darkroot
offline
Darkroot
2,763 posts
Peasant

What functions? I don't see a function on the whole page.

sourwhatup2
offline
sourwhatup2
3,660 posts
Jester

Wouldn't it work as DarkRoot said it?? If done right.

sourwhatup2
offline
sourwhatup2
3,660 posts
Jester

Oh.. well that does make sense Lol...

rjbman
offline
rjbman
215 posts
Nomad

gratz

sourwhatup2
offline
sourwhatup2
3,660 posts
Jester

gratz


Spam??

I think that's why he said it didn't work... because he copied and pasted thinking he put the right code and method... always check over a code before you think it's right.


Oh I didn't see that he copied and pasted it.
IxPvPxI
offline
IxPvPxI
86 posts
Nomad

Hmm. I'll try to get the one I used in the game im making atm.

Showing 1-13 of 18