Air for Android: Animation causes lagging in my game

后端 未结 1 1677
别那么骄傲
别那么骄傲 2021-01-26 01:41

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 o

相关标签:
1条回答
  • 2021-01-26 01:48

    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.

    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 can be moved around smoothly once converted to bitmap.

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

    0 讨论(0)
提交回复
热议问题