Moving a Character With The Arrow Keys
The following code when attached to a character will allow the character to be moved using the arrow keys:
onClipEvent (enterFrame) {
if (Key.isDown(37)) {
_x=_x-10;
}
if (Key.isDown(38)) {
_y=_y-10;
}
if (Key.isDown(39)) {
_x=_x+10;
}
if (Key.isDown(40)) {
_y=_y+10;
}
** Extra Code to stop character car going through walls:
if (hitTest(_level0.wall)==true) {
_x=_x-10;
}
if (hitTest(_level0.lft_wall)==true) {
_x=_x+10;
}
if (hitTest(_level0.lft_wall2)==true) {
_x=_x+10;
}
onClipEvent (enterFrame) {
if (Key.isDown(37)) {
_x=_x-10;
}
if (Key.isDown(38)) {
_y=_y-10;
}
if (Key.isDown(39)) {
_x=_x+10;
}
if (Key.isDown(40)) {
_y=_y+10;
}
** Extra Code to stop character car going through walls:
if (hitTest(_level0.wall)==true) {
_x=_x-10;
}
if (hitTest(_level0.lft_wall)==true) {
_x=_x+10;
}
if (hitTest(_level0.lft_wall2)==true) {
_x=_x+10;
}

1 Comments:
hey, I just got a free $500.00 Gift Card. you can redeem yours at Abercrombie & Fitch All you have to do to get yours is Click Here to get a $500 free gift card for your backtoschool wardrobe
Post a Comment
<< Home