Advanced Adobe Animate
Control MovieCLips With Keyboard Things to remember:
- Instance Names
- Code Snippets
- Scalex
- Keycodes
- Rotation
- MC.x
- Hittest - for Collision detection
Moving animation using keyboard, can any other keyboard button.
- Walk Angle
- Graphics symbolers
- Bone Tool
- COntoel with Keybaord and or mouse
Create movement with botton interaction. here i set the the Box on the left to move with WASD keys and the box on the right with the walking cycle to move with the arrows keys. A possible way to wave Mulitplayer interaction/Gameplay.
Code to Constrain Box within the Canvas Scene
Using cude to reset scene/object/ movie clip/grtaphic symbole postion with mouse click.
var test:Boolean = false;
stage.addEventListener(MouseEvent.CLICK, fl_ClickToPosition);
function fl_ClickToPosition(event:MouseEvent):void
{
if(test == true){
box_MC_1.x = 250;
box_MC_1.y = 250;
}
test = true;
}
Changing the direction of animation to the directionwith walking. Press left, to move left and face left.
if (leftPressed)
{
movieClip_1.x -= 1;
movieClip_1.scaleX = -1;
I had noticed that code snippet with in adobe animate used a different way for character movement.
var upPressed:Boolean = false;
var downPressed:Boolean = false;
var leftPressed:Boolean = false;
var rightPressed:Boolean = false;
movieClip_1.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey);
stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed);
unction fl_MoveInDirectionOfKey(event:Event)
{
if (upPressed)
{
movieClip_1.y -= 1;
}
if (downPressed)
{
movieClip_1.y += 1;
}
if (leftPressed)
{
movieClip_1.x -= 1;
}
if (rightPressed)
{
movieClip_1.x += 1;
}
}
function fl_SetKeyPressed(event:KeyboardEvent):void
{
switch (event.keyCode)
{
case Keyboard.UP:
{
upPressed = true;
break;
}
case Keyboard.DOWN:
{
downPressed = true;
break;
}
case Keyboard.LEFT:
{
leftPressed = true;
break;
}
case Keyboard.RIGHT:
{
rightPressed = true;
break;
}
}
}