[FONT=Arial]Hello![/FONT]
[FONT=Arial]I am developing a flash maze game and I have a problem with changing direction of my movie clip. I can move around my maze and I have a hit test sorted. But what I want is when a player presses a keyboard button, the first animation of the MC rotating will be played, then when the play head hits “stop” the MC will stay in this same position (pos from last frame) until another key for example “up” is pressed. [/FONT]
[FONT=Arial] [/FONT]
[FONT=Arial] [/FONT]
[FONT=Arial] [/FONT]
[FONT=Arial]Thanks a lot![/FONT]
[LEFT][FONT=Arial]function keyDownFunction(e:KeyboardEvent)
{
switch (e.keyCode)
{
case Keyboard.UP :
up=true;
newDir:"up"
break;[/FONT]
[FONT=Arial] case Keyboard.DOWN :
down=true;
newDir:"down"
break;
case Keyboard.LEFT :
left=true
newDir:"left"
break;
case Keyboard.RIGHT :
right=true;
newDir:"right"
break;
}[/FONT]
[FONT=Arial]hitTest();
}[/FONT]
[FONT=Arial]function keyUpFunction(e:KeyboardEvent)
{
switch (e.keyCode)
{
case Keyboard.UP :
up=false;
break;[/FONT]
[FONT=Arial]case Keyboard.DOWN :
down=false;
break;[/FONT]
[FONT=Arial]case Keyboard.LEFT :
left=false[/FONT]
[FONT=Arial]break;[/FONT]
[FONT=Arial]case Keyboard.RIGHT :
right=false;
break;
}
hitTest();
}
function slowDown(e:Event)
{
if(down && speed < maxspeed)
{
speed +=0.1;
if(speed > maxspeed){speed = maxspeed;}
}
if(down==false && speed >= -maxspeed/2)
{
if(speed >=0)
{
//trace(speed +" :speed2");
speed -=0.1;
}
}
}
function movePc(e:Event)
{
if( down )
{
currentDir:"down";
pc.y+=speed
pc.y+=1
if( wall.walls.hitTestPoint(pc.x,pc.y+pc.height,true) )
{
pc.y-=speed
//pc.y -=1
}
if( wall.walls.hitTestPoint(pc.x+pc.width,pc.y+pc.height,true) )
{
pc.y-=speed
//pc.y -=1
}
}
if( up )
{
currentDir="up";
pc.y -= 1;
if( wall.walls.hitTestPoint(pc.x,pc.y,true) )
{
pc.y += 1;
}
if( wall.walls.hitTestPoint(pc.x+pc.width,pc.y,true) )
{
pc.y += 1;
}
}
if( left )
{
currentDir="left";
pc.x -= 1;
if( wall.walls.hitTestPoint(pc.x,pc.y,true) )
{
pc.x += 1;
}
if( wall.walls.hitTestPoint(pc.x,pc.y+height,true) )
{
pc.x += 1;
}
/*pc.rotation+=5
if(pc.rotation>=90)
{
trace(pc.rotation);
pc.rotation-=5
}
*/
setDir()
}
if( right )
{
currentDir="right";
pc.x += 1;
if( wall.walls.hitTestPoint(pc.x+pc.width,pc.y,true) )
{
pc.x -= 1;
}
if( wall.walls.hitTestPoint(pc.x+pc.width,pc.y+height,true) )
{
pc.x -= 1;
}
}
}
[/FONT][/LEFT]