带箭头键的8向图形动画 [英] 8-direction Figure Animation with Arrow Keys

查看:120
本文介绍了带箭头键的8向图形动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我负责在ActionScript 3中为等距视频游戏设计演示。我有位图子画面,可以显示我在各个方向站立和行走所使用的化身。步行动画由三个帧组成。

I've been charged with designing a demo for an isometric video game in ActionScript 3. I have the bitmap spritesheets that show the avatar I'm using standing and walking in each direction. The walking animation is made up of three frames.

但是,我的问题是我需要弄清楚如何利用它们。我不熟悉Flash中的动画,因此需要输入有关如何向正确的方向移动行走帧gotoAndPlay()的信息。我不认为隔离必要的方向将不是一个挑战,就像在箭头键按下时启动并保持运行一样。

My problem, though, is that I need to figure out how to make use of them. I'm not familiar with animation in Flash, and I need input on how to gotoAndPlay() the walking frames for the right direction. I don't think isolating the necessary DIRECTION is going to be a challenge, so much as starting it and keeping it going while the arrow keys are down.

我当前的代码基本上由KEY_UP和KEY_DOWN的键盘处理程序组成,每个处理程序都包含更改Avatar.currentDirection属性的switch-case语句。按下键时,处理程序将继续触发,但是我需要向游戏中添加动画。

My current code is basically comprised of keyboard handlers for KEY_UP and KEY_DOWN, each containing a switch-case statement that changes the Avatar.currentDirection property. The handler continues to fire while the keys are down, but I need to add animation to the game.

我已经看到了一些示例,它们只是将动画嵌入到SWF会传播各个步行阶段的数组,并使用EnterFrame事件处理程序在各个步行阶段之间进行交替,但这似乎很笨拙。我猜想我最终还是想使用Adobe Animate,但是我不知道你该怎么做。

I've seen some examples where they simply embed the animations into an SWF, propagate an array of the various walking stages, and alternate between them using an EnterFrame event handler, but this seems really clunky. I guess in the end I'm trying to make use of Adobe Animate, but I don't know how you're supposed to do that.

推荐答案

对不起,幸运的是,我现在正在使用精灵(地图集动画)!。

Ops, fortunately i'm working with sprites (atlas animations) right now!.

如果我是对的,您只需要使用它们用于播放具有功能的动画。

if i'm right, you just needs to use them for playing some animation with functionality.

如果您有一个尺寸合适的精灵,并用像这样的等距插槽平铺:
(9个帧,大小为64x128 )

if you have a well sized sprite which is tiled with isometric slots like it: (9 frames sized 64x128)

您的工作是非常简单,只需从库中创建新的动画片段,在其内部,在图层(称为蒙版)中创建无边界矩形(这是我们的蒙版),然后将图像导入到项目中,这样可以更好地禁用图像属性的平滑功能,

your work is very easy, only create new movieclip from library, inside it, create a borderless rectangle (which is our mask) in a layer (named mask) then import image to the project, and its better to disabling smooth ability from image properties,

现在,在动画片段中,您必须创建一个新层(在遮罩层下)并为每个帧添加精灵图像,并更改其位置:

now, inside your movieclip, you have to create new layer (under the mask layer) and add your sprite image for each frame, and change its position:


最后,为遮罩层启用遮罩,然后

at last, enable masking for mask layer, then its time of coding,

指定其动画查询时间(如图像3),对于可循环播放的动画,请插入 gotoAndPlay( 'anim_name')在最后一帧内。我希望您熟悉控制flash剪辑的基本动画剪辑动画。

name your animation queries (like image 3) and for loopable animations, insert gotoAndPlay('anim_name') inside last frame. i hope you are familiar with controling movieclip animations which is basic consept of any flash project.

现在要将其扩展为8个方向的支持,您只需要根据单键和多键提示弹奏并在方向之间切换即可,

这篇关于带箭头键的8向图形动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆