PDA

View Full Version : having trouble with rpg demo


speedlemon
07-10-2004, 10:58 PM
i wanted to make a guy walk around similar to rpg maker 2000/2003.
i have a mc that is set up like this.
frames 1-3 : walking down
frames 4-6 : walking left
frames 7-9 : walking up
frames 10-12 : walking right

and i have this code to make it do the animations. (havent implemented walking yet. ;) ). for some reason this doesnt work? i was wondering if someone could show me why. please dont tell me how i could do it a better way or something. im new to actionscript, and i thought of this way all by myself so i understand it the most. :cool:

oh btw-
direction 3 = down
direction 4 = left
direction 1 = up
direction 2 = right
k?

onClipEvent (load) {
curframe = 1;
direction = 3;
}
onClipEvent (enterFrame) {
if (curframe=1) {
if (direction=3) {
gotoAndStop(2);
curframe = 2;
}
if (direction=4) {
gotoAndStop(5);
curframe = 2;
}
if (direction=1) {
gotoAndStop(8);
curframe = 2;
}
if (direction=2) {
gotoAndStop(11);
curframe = 2;
}
}
if (curframe=2) {
if (direction=3) {
gotoAndStop(3);
curframe = 3;
}
if (direction=4) {
gotoAndStop(6);
curframe = 3;
}
if (direction=1) {
gotoAndStop(9);
curframe = 3;
}
if (direction=2) {
gotoAndStop(12);
curframe = 3;
}
}
if (curframe=3) {
if (direction=3) {
gotoAndStop(1);
curframe = 1;
}
if (direction=4) {
gotoAndStop(4);
curframe = 1;
}
if (direction=1) {
gotoAndStop(7);
curframe = 1;
}
if (direction=2) {
gotoAndStop(10);
curframe = 1;
}
}
}

speedlemon
07-11-2004, 03:51 PM
well. than last night i was just messing around with it and something new to me. functions. =P. i added this to the very top.

function apple(a,b){
c = a+b;
}


i now realize that i did even that wrong. =P.
has nothing to do with the rest of the code. and it changed the way the rest of the code worked. it wasnt fixed, but it started showing some other parts of the animation. it just went through all of them like there werent any actionscript at all...

Ricod
07-12-2004, 06:33 AM
Did you happen to have read this tutorial ? (http://www.actionscript.org/tutorials/beginner/games_in_flash/index.shtml)

That`s a lot of if statements, but you just do "if ..." "if ..." "if ..." instead of using "if ...else" statements.

Furthermore, I think it`s better to seperate the animations from the code. It`s handier to just have a walking animation of each direction and just set it of when the character starts moving and stop the animation when the character stops moving. So, instead of deciding which frame to play next, just use : gotoAndPlay("walk_left"); to play the animation of the character walking to the left, once the left button is pressed (or whatever you use to decide the directions).

Sorry, I can`t show you an example .fla right now, since I`m not home (or will be in the next month or so).

speedlemon
07-12-2004, 05:12 PM
thanks for the reply.
you're the (one of the)only person(s) that answers my questions. =D

reading tutorial...

Ricod
07-13-2004, 03:37 AM
Nah, just happened to see the title and since gaming and gamecharacters are among my main interests ... :)

Also, a basic thingie : when you use if ... else statements, you can compare values by using the "==" operator. "=" means "give something the following value".


if (direction==1) {
gotoAndStop(8);
curframe = 2;
}
Just in case you wish to keep this setup.

Cannon2004
08-11-2004, 03:00 AM
Did you happen to have read this tutorial ? (http://www.actionscript.org/tutorials/beginner/games_in_flash/index.shtml)

That`s a lot of if statements, but you just do "if ..." "if ..." "if ..." instead of using "if ...else" statements.

Furthermore, I think it`s better to seperate the animations from the code. It`s handier to just have a walking animation of each direction and just set it of when the character starts moving and stop the animation when the character stops moving. So, instead of deciding which frame to play next, just use : gotoAndPlay("walk_left"); to play the animation of the character walking to the left, once the left button is pressed (or whatever you use to decide the directions).

Sorry, I can`t show you an example .fla right now, since I`m not home (or will be in the next month or so).

But where should the movie clip Walk_Left Be stored at? In the Library?

Wateva_tbh
08-11-2004, 03:48 PM
I did something similar to this a little while ago, if you want a look at it

http://www.apex-uk.biz/Mananim.fla

Think it's kinda similar to what you're talking about, plus it's got a kinda collision thing as well.