主题:  飞行windows的屏保

rainy_5d

职务:普通成员
等级:2
金币:1.0
发贴:225
#12001/7/22 14:40:12
前几天,看到飞行windows的屏保挺有意思,试着写了一下,对飞行路线的控制不很满意,请高手指教,如何才能做出windows自带屏保的飞行效果。

做一个windows的bmp或者shape,拖动到stage,然后将脚本赋给sprite,当然是sprite越多越好了,我用了大概是100个吧。

behavior如下:

-------------------------------------------------
--类似飞行windows屏幕保护的Behavior
--Rainy copyright 2001
-------------------------------------------------
-------------------------------------------------
property pStageW,pStageH --屏幕宽度和高度 int
property pStartPoint --起始点 point(h,v)
property pMovePixcel --初始化移动速度 int
--property pAddMoveTime --增加多少次后加速 int
property pAddMovePixcel --加速度为多少 int
property pChangeSprite --改变精灵大小 int
property pMySpriteW,pMySpriteH --精灵原先大小 int
property pMySpriteFW --精灵方位 symbol #myleftT & #myLeftB & #myrightT & myRightB
property pMySpriteJD --精灵移动的角度
property pMySprite
property pMySpriteWH --精灵的宽高比例
-------------------------------------------------
on getPropertyDescriptionList me
mylist=[:]
addprop mylist,#pMovePixcel,[#comment:"移动速度",#default:1, \
#format:#integer,#range:[#min:1,#max:10]]
addprop mylist,#pChangeSprite,[#comment:"改变大小",#default:3, \
#format:#integer,#range:[#min:1,#max:10]]
-- addprop mylist,#pAddMoveTime,[#comment:"多少次后加速",#default:8, \
-- #format:#integer,#range:[#min:1,#max:10]]
addprop mylist,#pAddMovePixcel,[#comment:"增加后的速度是",#default:15, \
#format:#integer,#range:[#min:1,#max:20]]
return mylist
end getPropertyDescriptionList

-------------------------------------------------
on beginsprite me
puppetSprite me.spriteNum,True

pMySpriteJD=45.0

pStageW=the stage.rect.width
pStageH=the stage.rect.height

tempx=random(pstagew)
tempy=random(pstageh)
pStartPoint=point(tempx,tempy) --win的初始位置为随机

if tempx<=pStageW/2 then --判断方位 左 or 右
if tempy<=pStageH/2 then
pMySpriteFW=#myLeftT
else
pMySpriteFW=#myLeftB
end if
else
if tempy<=pStageH/2 then
pMySpriteFW=#myRightT
else
pMySpriteFW=#myRightB
end if
end if

pMySprite=sprite(me.spriteNum)
pMySpriteW=pMySprite.width
pMySpriteH=pMySprite.Height

--求宽度和高度的比例
pMySpriteWH=float(pMySpriteW/pMySpriteH)

pMySprite.loc=pStartPoint
pMySprite.width=1
pMySprite.height=1
pMySprite.ink=36
me.changeSpriteColor()
end
-------------------------------------------------
--移动精灵 参数:移动速度
on moveSprite me,moveSD
if (pMySprite.locH>0 and pmySprite.locH0 and pmySprite.locV myDirection=me.getDirection() --得到角度
pMySprite.locH=pMySprite.locH+moveSD*cos(myDirection*pi()/180)
pMySprite.locV=pMySprite.locV+moveSD*sin(myDirection*pi()/180)
else
me.beginsprite()
me.changeSpriteColor()
end if
end
-------------------------------------------------
--得到精灵方向
--注意:将屏幕分成4部分,left & right,其中各3个方向
on getDirection me
tempDirection=random(3) --随机3个方向
round=360.0
case tempDirection of
1:
case pMySpriteFW of
#myLeftT,#myRightT:
return round
#myLeftB,#myRightB:
return round-pMySpriteJD*4
end case
2:
case pMySpriteFW of
#myLeftT:
return round-pMySpriteJD
#myRightT:
return pMySpriteJD
#myLeftB:
return round-pMySpriteJD*3
#myRightB:
return pMySpriteJD*3
end case
3:
case pMySpriteFW of
#myLeftT,#myLeftB:
return round-pMySpriteJD*2
#myRightT,#myRightB:
return pMySpriteJD*2
end case
end case
end
-------------------------------------------------
--改变精灵大小
on changeSpriteWH me
if pMySprite.height>pMySpriteH then exit
pmysprite.width=pmysprite.width+pChangeSprite*pMySpriteWH
pmysprite.height=pmysprite.height+pChangeSprite
me.moveSprite(pMovePixcel)
end
-------------------------------------------------
--改变精灵颜色
on changeSpriteColor me
tempcolor=random(255)
pMySprite.forecolor=tempcolor
updateStage
end
-------------------------------------------------
on exitFrame me
me.changeSpriteWH()
me.moveSprite(pAddMovePixcel)
end