※ 引述《etrexetrex (moonet)》之銘言:
: 自己作完之後
: 覺得好像沒什麼東西能給人看
: http://et284vu065k3.googlepages.com/banner.html
: 可是又覺得很可愛
: 想給大家看一下
: 真猶豫
有人問到原始碼
我就公開一下好了
http://et284vu065k3.googlepages.com/banner.fla
== 不想點連結的可以直接看code ==
import flash.geom.Transform;
import flash.geom.ColorTransform;
var i = 0 ;
var speed = 5;
onEnterFrame = function()
{
i++;
if(i % speed == 0)
{
var head = panel.attachMovie("head",i,i);
head._xscale = head._yscale = Math.random()*30 + 40;
setColor(head,Math.random()*0.2+0.8,
Math.random()*0.2+0.8,
Math.random()*0.2+0.8);
//上下左右出
if(Math.random() > 0.1)
{
//上下出
if(Math.random() > 0.5)
{
//上
head._x = Math.random()*500 +50;
head._y = 45;
head._rotation = 180 + Math.random() * 60 - 30;
}
else
{
//下
head._x = Math.random()*500 +50;
head._y = 91;
head._rotation = 0 + Math.random() * 60 - 30;
}
}
else
{
//左右出
if(Math.random() > 0.9)
{
//左
head._x = 45;
head._y = Math.random()*70 +30;
head._rotation = 90 + Math.random() * 60 - 30;
}
else
{
//右
head._x = 555;
head._y = Math.random()*70 +30;
head._rotation = 270 + Math.random() * 60 - 30;
}
}
}
}
function setColor(MC,r,g,b)
{
//link
var trans:Transform = new Transform(MC);
var newColorTransform:ColorTransform =
new ColorTransform(r, g, b, 1, 0, 0, 0, 0);
trans.colorTransform = newColorTransform;
}
==
主要是用 if( 亂數 > 某值)
來控制人頭出現在各個方向的機率
其實沒什麼重點
完全土法煉鋼
--
blog:http://etrex.blogspot.com/
site:http://web.ntust.edu.tw/~B9409041/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.160.145.221