1.建立一个圆和一根指针形状
1 let circle = new egret.Shape(); 2 circle.graphics.lineStyle(5,0x000000,1,true); 3 circle.graphics.drawCircle(0,0,170); 4 circle.graphics.endFill(); 5 circle.x = Main.instance.stage.stageWidth/2; 6 circle.y = Main.instance.stage.stageHeight/2; 7 this.addChild(circle); 8 9 this.pointer = new egret.Shape(); 10 this.pointer.graphics.beginFill(0xFF9900,1); 11 this.pointer.graphics.drawRect(0,0,160,5); 12 this.pointer.graphics.endFill(); 13 this.pointer.anchorOffsetY = this.pointer.height/2; 14 this.pointer.x = Main.instance.stage.stageWidth/2; 15 this.pointer.y = Main.instance.stage.stageHeight/2; 16 this.addChild(this.pointer);
2.添加Timer计时器,每秒钟走1格,走60格走完一圈
1 this.timer = new egret.Timer(1000,0); this.timer.addEventListener(egret.TimerEvent.TIMER,this.timerFun,this); 2 this.timer.start();
1 private timerFun(){ 2 this.pointer.rotation += 6; 3 // console.log(‘this.pointer.rotation = ‘+this.pointer.rotation); 4 }
3.效果
原文地址:https://www.cnblogs.com/WentingC/p/9289741.html
时间: 2024-11-09 05:59:16