适用于Android的Air:动画导致游戏延迟 [英] Air for Android: Animation causes lagging in my game

查看:97
本文介绍了适用于Android的Air:动画导致游戏延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用CS6 Air开发一款适用于Android的游戏。
在为游戏制作动画时,我使用3D软件混合器。在Blender中,我制作了一个动画,然后将其渲染为一系列PNG图像,并将其导入到Flash CS6中。
因此,如果我要为角色制作行走动画,则需要在Blender中制作约30张png图像,并将其作为序列导入。大多数情况下,这种效果很好,但是我制作的某些动画存在问题。
例如,我有一个爆炸的敌人的动画。所以在我的游戏中,有时同时有很多敌人,当我单击它们时它们会爆炸。但是爆炸动画使游戏变得很迟钝。

I'm making a game in cs6 air for android. When I make animations for my game, I use the 3D software blender. In blender I make an animation, and then render it as a sequence of PNG images, which I import to Flash CS6. So if I'm making a walk animation for my character, I make around 30 png images i blender, and import them as a sequence. This works pretty well most of the time, but I have a problem with some of the animations I made. As an example I have an animation of an enemy that explodes. So in my game, there is sometimes a lot of enemies at the same time, and they explode when I click on them. But the explode animation makes the game pretty laggy.

问题:
是否有可能将png图像转换为其他图像的方法?落后?我制作的大多数其他动画都没有落后。我不知道爆炸动画可能特别重。我知道我可以在cs6中自己绘制动画,然后它不会滞后,但是会花费很多时间,而且看起来不那么酷。

The question: Is there a way to maybe convert the png images to something else, that doesn't lag? Most of the other animations I made works without lagging. Maybe the explode animation is especially heavy, I don't know. I know that I could draw the animation myself in cs6, and then it would not lag, but it would take a lot of time, and not look as cool.

我希望我已经说清楚了,谢谢!!

I hope I made myself clear, and thanks in advance!

推荐答案

仅使用位图-其他一切都必须脱离舞台。位图使用gpu,其他所有内容使用cpu。您可以使用任何方法创建常规mc,但可以将其转换为位图。显示加载屏幕,将png文件加载到mc中,将mc转换为位图,删除png文件,移除加载屏幕并运行。

Only use bitmaps - everything else has to be off the stage. Bitmaps use the gpu, everything else uses the cpu. You can use whatever to create regular mc's but convert them to bitmap. Show a loading screen, load your png files into mc's, convert mc's into bitmaps, delete png files, remove loading screen and run.

以下是用于从中创建位图的示例函数mc的。代码显示了用位图副本替换常规向量mc:

Here's example function for creating bitmaps out of mc's. The code shows replacing a regular vector mc with a bitmap copy:

var bmpTemp: Bitmap;
bmpTemp = fDrawTile(mcVector, 0, 0, iWidth, iHeight);
mcHolder.mcBitmap.addChild(bmpTemp);
mcHolder.removeChild(mcHolder.mcVector);
mcHolder.mcVector = null;


function fDrawTile(pClip: MovieClip, pX: int, pY: int, pWidth: int, pHeight: int): Bitmap {
    trace("fDrawTile: " + pX + "," + pY + "  " + pWidth + "," + pHeight);
    var rectTemp: Rectangle = new Rectangle(pX, pY, pWidth, pHeight);
    var bdClip: BitmapData = new BitmapData(pWidth, pHeight, true, 0x00000000);
    var bdTemp: BitmapData = new BitmapData(pWidth, pHeight, true, 0x00000000);
    bdClip.draw(pClip, null, null, null, rectTemp, true);
    bdTemp.copyPixels(bdClip, rectTemp, new Point(0, 0));
    var bmpReturn: Bitmap = new Bitmap(bdTemp, "auto", true);
    return bmpReturn;
}

mcHolder转换为位图后可以平滑地移动。

mcHolder can be moved around smoothly once converted to bitmap.

此方法非常强大,因为您可以在运行时创建图像。

This method is so powerful because you can create images at runtime.

这篇关于适用于Android的Air:动画导致游戏延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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