仅仅是对一幅位图进行不间断的旋转(改变其rotation属性),CPU占用率就达到了15以上,如果同时再移动它那么占用的就更高了。
很不理解为什么在网上看到的一些3D效果(比如roxik的樱花3D)几乎都看不到CPU在动,而我仅仅是对一幅位图进行了简单的移动、旋转CPU就这么厉害了
是我写的有问题么。。?
复制内容到剪贴板
代码:
package
{
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.StageScaleMode;
import flash.display.Stage;
/**
* ...
* @author DefaultUser (Tools -> Custom Arguments...)
*/
public class Test_CPU extends Sprite
{
var a:aa;
var s:Bitmap;
public function Test_CPU():void
{
init();
}
function init():void
{
stage.scaleMode = StageScaleMode.NO_SCALE;
a = new aa();
s = reset_s(a);
addChild(s);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mm);
addEventListener(Event.ENTER_FRAME, en);
}
function en(evt:Event):void
{
s.rotation += 1;
}
function mm(evt:MouseEvent):void
{
s.x = mouseX;
s.y = mouseY;
}
function reset_s(s:Sprite):Bitmap
{
var w:int = 350;
var h:int = 500;
var bitmapdata:BitmapData = new BitmapData(s.width, s.height)
bitmapdata.draw(s);
var bitmap:Bitmap = new Bitmap(bitmapdata);
bitmap.smoothing = true;
if (bitmap.width > w)
{
bitmap.height *= w / bitmap.width;
bitmap.width = w;
}
if (bitmap.height > h)
{
bitmap.width *= h / bitmap.height;
bitmap.height = h;
}
return bitmap;
}
}
}