Help converting game from AS2...
...to AS3.
Hi, I am wondering if there is anyone who can help with the conversion of this code I need to convert it to AS3 but not sure what needs to be changed.
All this code was on the character I was using.
I hope someone can help.
Code:
onClipEvent (load) {
gravity = 10;
scale = _xscale;
walkSpeed = 10;
maxjump = 6;
}
onClipEvent (enterFrame) {
if (air == true) {
_y += gravity;
state = 3;
}
if (Key.isDown(Key.LEFT) && !_root.leftbound.hitTest(_x, _y, true)) {
_x -= walkSpeed;
_xscale = -scale;
}
if (Key.isDown(Key.RIGHT) && !_root.rightbound.hitTest(_x, _y, true)) {
_x += walkSpeed;
_xscale = scale;
}
if (_root.platforms.hitTest(_x, _y, true)) {
air = false;
} else {
air = true;
}
if (Key.isDown(Key.SPACE) && jump == true) {
_y -= jumpSpeed;
}
if (air == false) {
jump = true;
jumpcount = 0;
jumpSpeed = 22;
}
if (Key.isDown(Key.SPACE)) {
jumpcount += 1;
}
if (jumpcount > maxjump && jumpSpeed > -2) {
jumpSpeed -= 2;
}
if (air == false && !Key.isDown(Key.LEFT) && !Key.isDown(65) or air == false && !Key.isDown(Key.RIGHT) && !Key.isDown(65)) {
state = 1;
}
if (Key.isDown(Key.LEFT) && air == false && !Key.isDown(65) or Key.isDown(Key.RIGHT) && air == false && !Key.isDown(65)) {
state = 2;
}
if (!Key.isDown(65)) {
gotoAndStop(state);
}
_root.statetxt = state;
}
onClipEvent (keyUp) {
if (Key.getCode() == 83) {
jump = false;
}
}
Help Game Converting to AS3
Hello im wondering if anyone could help me convert my old game code of AS2 to AS3, Im not expecting someone to do it for me (though it would be helpful :P ) just how I would go about doing it. Currently the code from AS2 was all on my main character but im looking to import my character from the library using a .AS in AS3. I've managed to convert the keyboard functions it's just mainly making platforms and the character to land on them.
The code is as follows:
Code:
onClipEvent (load) {
gravity = 10;
scale = _xscale;
walkSpeed = 10;
maxjump = 6;
}
onClipEvent (enterFrame) {
if (air == true) {
_y += gravity;
state = 3;
}
if (Key.isDown(Key.LEFT) && !_root.leftbound.hitTest(_x, _y, true)) {
_x -= walkSpeed;
_xscale = -scale;
}
if (Key.isDown(Key.RIGHT) && !_root.rightbound.hitTest(_x, _y, true)) {
_x += walkSpeed;
_xscale = scale;
}
if (_root.platforms.hitTest(_x, _y, true)) {
air = false;
} else {
air = true;
}
if (Key.isDown(Key.SPACE) && jump == true) {
_y -= jumpSpeed;
}
if (air == false) {
jump = true;
jumpcount = 0;
jumpSpeed = 22;
}
if (Key.isDown(Key.SPACE)) {
jumpcount += 1;
}
if (jumpcount > maxjump && jumpSpeed > -2) {
jumpSpeed -= 2;
}
if (air == false && !Key.isDown(Key.LEFT) && !Key.isDown(65) or air == false && !Key.isDown(Key.RIGHT) && !Key.isDown(65)) {
state = 1;
}
if (Key.isDown(Key.LEFT) && air == false && !Key.isDown(65) or Key.isDown(Key.RIGHT) && air == false && !Key.isDown(65)) {
state = 2;
}
if (!Key.isDown(65)) {
gotoAndStop(state);
}
_root.statetxt = state;
}
onClipEvent (keyUp) {
if (Key.getCode() == 83) {
jump = false;
}
}
I hope someone can help :)