got the character to swap symbols but still does not work correctly
need to find a different way to get the character working
function onKeyPressed(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.RIGHT)
{
isRightPressed = true;
}
if(event.keyCode == Keyboard.LEFT)
{
isLeftPressed = true;
}
if(event.keyCode == Keyboard.SPACE)
{
isSpacePressed = true;
}
}
function onKeyReleased(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.LEFT)
{
isLeftPressed = false;
}
if(event.keyCode == Keyboard.RIGHT)
{
isRightPressed = false;
}
if(event.keyCode == Keyboard.SPACE)
{
isSpacePressed = false;
}
}
function addAgent():void
{
addChild(agent_mc);
if(isLeftPressed == true)
{
removeChild(agent_mc);
addChild(agentRun_mc);
agentRun_mc.x = agent_mc.x;
agentRun_mc.y = agent_mc.y;
isAgentRunningLeft = true;
if(isAgentRunningLeft == false)
{
removeChild(agentRun_mc);
addChild(agent_mc);
}
}
if(isRightPressed == true)
{
removeChild(agent_mc);
agentRun_mc.x = agent_mc.x;
agentRun_mc.y = agent_mc.y;
addChild(agentRun_mc);
isAgentRunningRight = true;
if(isAgentRunningRight == false)
{
removeChild(agentRun_mc);
addChild(agent_mc);
}
}
if(isSpacePressed == true)
{
removeChild(agent_mc);
agentAttack_mc.x = agent_mc.x;
agentAttack_mc.y = agent_mc.y;
addChild(agentAttack_mc);
isAgentAttacking = true;
if(isAgentAttacking == false)
{
removeChild(agentAttack_mc);
addChild(agent_mc);
}
}
}
function moveAgent():void
{
if(isAgentRunningRight == true)
{
agent_mc.x += AGENT_SPEED;
agentRun_mc.scaleX = .3;
agentRun_mc.scaleY = .3;
}
if(isAgentRunningLeft == true)
{
agent_mc.x -= AGENT_SPEED;
agentRun_mc.scaleX = .3;
agentRun_mc.scaleY = .3;
}
if(isAgentAttacking == true)
{
agentAttack_mc.scaleX = .3;
agentAttack_mc.scaleY = .3;
}
}
No comments:
Post a Comment