zoukankan      html  css  js  c++  java
  • Egret--添加一个精灵事件

    class Hello extends egret.DisplayObjectContainer{
    	//入口函数
    	 private onAddStage(event:egret.Event){
    		//打开性能面板
    		 //egret.Profiler.getInstance().run();
    		console.log("heool");
    	}
    	//构造函数
    	public constructor() {
    		super();
    		//调用方法 且添加一个精灵事件
    		//this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAddStage,this);
    		this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAddToStage,this);
    	}
     
    	//初始化函数 
    	//参数:事件函数
    	private onAddToStage(event:egret.Event){
    		//绘制一个图形 实例化操作
    		var spr:egret.Sprite=new egret.Sprite();
    		//为看到效果 在容器内加一图形
    		//在beginFill内指定颜色 0x+红色
    		spr.graphics.beginFill(0xff0000);
    		//绘制当前图形 位置大小
    		spr.graphics.drawRect(50,50,100,100);
    		//结束绘制
    		spr.graphics.endFill();
    		//可以通过x.y改变位置
    		spr.x=100;
    		spr.y=200;
    		//scaleX横向缩放;scaleY纵向缩放
    		spr.scaleX=0.5;
    		spr.scaleY=0.5;
    		//alpha:0到1 透明度
    		spr.alpha=0.2;
    		//旋转角度
    		spr.rotation=45;
    		//添加到容器/舞台
    		this.addChild(spr);
    		//skewY skewX:斜切
    		//visible:可见与否
    
    	}
    }
    

      

  • 相关阅读:
    【bzoj1010】[HNOI2008]玩具装箱toy
    bzoj 3173
    bzoj 1179
    bzoj 2427
    bzoj 1051
    bzoj 1877
    bzoj 1066
    bzoj 2127
    bzoj 1412
    bzoj 3438
  • 原文地址:https://www.cnblogs.com/allyh/p/10680109.html
Copyright © 2011-2022 走看看