一聚教程网:一个值得你收藏的教程网站

热门教程

flash9太阳地球月亮系统

时间:2022-07-02 17:16:59 编辑:袖梨 来源:一聚教程网

除了背景以外,全部使用as3代码:

var sun:Sprite = new Sprite();
sun.graphics.lineStyle(0,0xFF6600);
sun.graphics.beginFill(0xFF3300);
sun.graphics.drawCircle(0,0,40);
sun.graphics.endFill();

var earth:Sprite = new Sprite();
earth.graphics.lineStyle(0,0x92E9FE);
earth.graphics.beginFill(0x00CCFF);
earth.graphics.drawCircle(0,0,20);
earth.graphics.endFill();

var spot:Shape = new Shape();
spot.graphics.lineStyle(0,0x000000);
spot.graphics.beginFill(0x333333);
spot.graphics.drawCircle(0,0,2);
spot.graphics.endFill();

var moon:Shape = new Shape();
moon.graphics.lineStyle(0,0xFFFFCC);
moon.graphics.beginFill(0xFFFF00);
moon.graphics.drawCircle(0,0,5);
moon.graphics.endFill();

this.addChild(sun);
sun.x = 200;
sun.y = 200;

sun.addChild(spot);
spot.x = 20;
spot.y = 10;

sun.addChild(earth);
earth.x = 120;
earth.y = 0;

earth.addChild(moon);
moon.x = 50;
moon.y = 0;

stage.addEventListener(Event.ENTER_FRAME, orbit);

function orbit(evt:Event):void {
 
 sun.rotation++;
 
 earth.rotation+= 3;
 
 moon.rotation-=5;
 
}

热门栏目