PDA

View Full Version : Keyboard control for playing different MCs


diakonas
12-03-2003, 10:32 AM
Hi there!

What I want: (rough example)

when press Key "Right arrow", "Boy_mc" walk, when press "Right arrow" and "Ctrl", "Boy_mc" run, "Space", "Boy_mc" jump,...

So, how to make it? I could set variables "speed" for "walk" and "fast" for "run", but its still only speed of moving movie clip. I want, the "Boy_mc" within "run" move faster its legs and so on...

Idea: (rough example)

Create movie clips for each movement on one timeline, so finally I sould have:
"Boy_mc_walk"(from frame 1 to 5),
"Boy_mc_run"(from frame 6 to 10),
"Boy_mc_jump" (from frame 11 to 15),...

and the Script should look like this:
(I doesnt have any particular code writed down yet....)

function moveBoy() {
if (Key.IsDown(Key.RIGHT))
{ this._x += this.speed;
gotoAndPlay(1);}

if (Key.IsDown(key.RIGHT)) && (Key.IsDown(Key.CONTROL))
{ this._x += this.fast;
gotoAndPlay(6);}

if (Key.IsDown(Key.RIGHT)) && (Key.IsDown(Key.CONTROL)) && (Key.IsDown(Key.SPACE))
{ this._x += fast;
gotoAndPlay(11);}

}
Boy_mc.speed = 2;
Boy_mc.fast = 10;



OK - its only for illustration, I dont know, if this code work...
Sorry for mistakes, Im still beginer. I hope, its clear, what I want to ask. Any suggestions are wellcome

Thanks, frost

webguy
12-03-2003, 10:53 AM
http://www.actionscript.org/forums/showthread.php3?s=&threadid=19349
http://www.actionscript.org/forums/showthread.php3?s=&threadid=24973
http://www.actionscript.org/forums/showthread.php3?s=&threadid=28195
http://www.actionscript.org/forums/showthread.php3?s=&threadid=28214

got these threads from CyanBlue's 500 useful threads

http://www.actionscript.org/forums/showthread.php3?s=&threadid=38658

webG

webguy
12-03-2003, 11:36 AM
bah... where is my automatic formatting.. guess it isn't in the quickpost. I'll edit it.

CyanBlue
12-03-2003, 11:52 AM
Yup... That goes with the quick reply box... :(
(Copy the topic name for the threads so that somebody don't have to read all the question??? :D)