PDA

View Full Version : Side-scrolling game question


MuRkYsLaYeR
07-23-2002, 05:43 AM
I'm working on making a side-scrolling game that has this ninja guy that runs around fighting enemies. I have the moving and background scrolling scripts complete, but I don't know how to make it show his walk animation while he moves, the idle animation while he's not moving, and how to show the sword animation when you hit enter. Any ideas? Thanks

xxlm
07-23-2002, 07:49 AM
Your controler is on a MC isn't it... If not it should be on it... In that case you can at every frame do an action...

Then you have your dummy... Only put on this dummy Mc all the states it have (up, crouch, walking, sword, and so on ...).
Then from the controler, gotoAndPlay() them...
I've made this before (and never finish it)... Look for it and send it to you...

:D

xxlm
07-23-2002, 08:06 AM
here is the link to the zip file of my old old old dummy
http://www.lagoon.nc/xavier/fight/chunli_zero.zip
(1mb)

The char is only for the example...
Don't forget to look in your controler if your oldstate == the state you want. In that case don't gotoAndplay.yourdummy.("yourstate"); And only do the move function (or else);

PS:import the chunli_zero.swf into a enmptyMC

Ok?

:)

MuRkYsLaYeR
07-23-2002, 03:06 PM
Um...? I think I got most of what you said, thanks for the file, I'll check it out.

MuRkYsLaYeR
07-23-2002, 03:25 PM
Yeah, I looked that .fla file over and that's exactly what I had done, but what is the actionscript for it? EXAMPLE:
you press control, and it shows the punch animation.

I tried this:

if (keyDown(CONTROL)) {
guy.gotoAndPlay(2);
}


That didn't work though.

xxlm
07-23-2002, 03:40 PM
In your main scene you have,

A MC called "CONTROLER". Then on it

onClipEvent(enterFrame) {
if (key.RIGHT) {
if (_root.state <> "RIGHT") {
_root.MyDummyMC.gotoAndPlay("RIGHTState");
_root.state = "RIGHT";
}
_root.MyDummyMC._x += 10; // the speed of your char
}

if (key.LEFT) {
if (_root.state <> ...) {
...
}

//your different state and action

}


and for your code, it should be

if (Key.isDown(codeforControl)) {
_root.yourpath.guy.gotoAndPlay(2);
}

// OR

if (Key.CONTROL) {
_root.yourpath.guy.gotoAndPlay(2);
}


Is it what you're looking for ?
:confused:

MuRkYsLaYeR
07-23-2002, 03:42 PM
Yes I believe it is...what is the "yourpath" part of this though?
I put in the script you showed for a controller MC and modified it to this:

onClipEvent (enterFrame) {
if (key.isDown(CONTROL)) {
if (_root.state<>"RIGHT") {
_root.guy.gotoAndPlay("jump");
_root.state = "jump";
}
_root.guy._x+=5;
}
}

but that doesn't work still! =/

xxlm
07-23-2002, 04:00 PM
Ok man, i'll explain all the line of the code...

onClipEvent (enterFrame) {
if (key.isDown(keycode)) { // keycode is i.e 17 for the CONTROL key
if (_root.state<>"jump") { // look if you already gotoAndPlay the appropriate frame
_root.guy.gotoAndPlay("jump"); // if not so play your dummy
_root.state = "jump"; // you've played the dummy state
}
_root.guy._x+=5;
}
}


The yourpath is where you dummy is.
Look at the dummy you've got in my example... When you play the first frame of a state then it loops... That's why I look in the controler if the state I want is already played...
See what I mean ?

:)

Ricod
07-23-2002, 04:02 PM
the yourpath refers to your path. Since its not known to us ... lets say your path is _root.myGame.myGuy.Guy; well, that be your path, but since we don't know that ...

did u check _root.state ? Is there a label "jump" in _root.guy ? Are both the guy as the control mc in the same _level ?

MuRkYsLaYeR
07-23-2002, 04:44 PM
Alright I have the jump part working now. One problem though, the jump only works the first time I hit control, after that it doesn't work anymore.
here's how I have the "guy" MC set up:
=FRAME ONE=
standing still
-actions-
stop();

=FRAMES TWO THRU EIGHT=
jumping
-actions-
on frame eight-
gotoAndPlay(1);

xxlm
07-23-2002, 05:17 PM
You have to loop only the state... I.e:
1.
State "Jump" 2->8
The on the frame 8 you have

gotoAndPlay(2);


State "Run" 9->25
on the frame 25 you have

gotoAndPlay(9);


Then if you prees the run key, the controler play the frame 9 and then the char will loop to the state run...

If no key is pressed on the next frame of your movie, then your controller will stop to the "standby" state (or play if your dummy have an alnimation for this state... then do as the others).

:)

xxlm
07-23-2002, 05:33 PM
Don't forget to change your state at each key press or not press (standby state).

i.e for your standby state

if (!Key.UP && !Key.RIGHT && ...) {
if (_root.state <> "StandBy") {
_root.guy.gotoAndStop("StandBy");
_root.state = "StandBy";
}
}

Voilou... ;)

MuRkYsLaYeR
07-23-2002, 05:46 PM
Ok I'll try to work on it from what you've shown me. Thanks again =D!

xxlm
07-23-2002, 06:08 PM
:) :p :D