[]LayaAir引擎与原生Flash的差异文档说明!

已邀请:

cuixueying

赞同来自:

1、LayaAir与Flash的差异文档
a.int强转;
flash环境下:
       var a:int = int(1.5);
LayaAir环境下:
       var a:int = parseInt(1.5);

b.mask遮罩使用;
flash环境下:
1、静态遮罩
            var sp:Sprite=new Sprite();
sp.graphics.beginFill(0xFFFF00);
sp.graphics.drawRect(0,0,200,200);
sp.graphics.endFill();
addChild(sp);

var mask:Sprite=new Sprite();
mask.graphics.beginFill(0xFF0000);
mask.graphics.drawCircle(0,0,50);
mask.graphics.endFill();
sp.mask=mask
2、动态遮罩
            var sp:Sprite=new Sprite();
sp.graphics.beginFill(0xFFFF00);
sp.graphics.drawRect(0,0,200,200);
sp.graphics.endFill();
addChild(sp);

var mask:Sprite=new Sprite();
mask.graphics.beginFill(0xFF0000);
mask.graphics.drawCircle(0,0,50);
mask.graphics.endFill();
sp.mask=mask;

addEventListener(Event.ENTER_FRAME,function():void
{
mask.x++;
mask.cacheAsBitmap=true;
sp.cacheAsBitmap=true;
});






LayaAir环境下:
1、静态遮罩 
            Laya.init(600,400)
var sp:Sprite=new Sprite();
sp.graphics.drawRect(0,0,200,200,'#FFFF00');
Laya.stage.addChild(sp);

var mask:Sprite=new Sprite();
mask.graphics.drawCircle(0,0,50,'#FF0000');
sp.mask=mask;
2、动态遮罩 
            Laya.init(600,400)
var sp:Sprite=new Sprite();
sp.graphics.drawRect(0,0,200,200,'#FFFF00');
Laya.stage.addChild(sp);

var mask:Sprite=new Sprite();
mask.graphics.drawCircle(0,0,50,'#FF0000');
sp.mask=mask;

Laya.timer.frameLoop(1,this,function():void
{
mask.x++;
sp.repaint();
});
小提示:
       LayaAir下,Mask是添加到了显示对象内部,也就是说,LayaAir 下的Mask坐标是相对于被遮罩
对象的,而并非舞台。

c.精灵自身画的graphics矢量图形注册事件点击区域差异;
flash环境下:
            var sprite:Sprite = new Sprite();
sprite.graphics.beginFill(0xffcc00);
sprite.graphics.drawRect(100,100,100,100);
sprite.graphics.endFill();
addChild(sprite);
sprite.addEventListener(MouseEvent.CLICK,onClick);
function onClick(evt:MouseEvent):void
{
trace("------aaa---------");
}
LayaAir环境下:
            var sprite:Sprite = new Sprite();
//方法一------start
sprite.graphics.drawRect(100,100,100,100,"#ff9900");
var hitarea:HitArea = new HitArea();
var graphics:Graphics = new Graphics();
graphics.drawRect(100,100,100,100,"#ff9900");
hitarea.hit = graphics;
sprite.hitArea = hitarea;
//方法一------end

//方法二------start
sprite.graphics.drawRect(0,0,100,100,"#ff9900");
sprite.size(100,100);
Laya.stage.addChild(sprite);
sprite.on(Event.CLICK,this,onClick);
function onClick(evt:Event):void
{
trace("-------click--------");
}
//方法二------end

d.事件对象派发;
flash环境下:
派发:
        dispatchEvent('custom');
监听:  
         addEventListener('custom',onCustom)

LayaAir环境下:
var sprite:Sprite = new Sprite();
派发:
sprite.event('custom');
监听: 
 sprite.on('custom',this,onCustom

ohkei - as3、as2、h5

赞同来自:

感谢汇总!继续加油!

要回复问题请先

商务合作
商务合作