[問題] 一個javascript的問題

phpBB 2 MOD Support
無論是官方或非官方認證之外掛,安裝與使用問題討論。
(發表文章請按照公告格式發表,違者砍文)

版主: 版主管理群

主題已鎖定
雪曼
星球普通子民
星球普通子民
文章: 7
註冊時間: 2005-09-03 12:07
來自: 雪曼星

[問題] 一個javascript的問題

文章 雪曼 »

美化PHPBB首頁=櫻花紛飛的小邪楓大提供了一個java可以讓圖片在頁面飄落\r
請問如果要把它的飄落速度變慢該從哪裡著手?

原文:
打開風格的index_body.tpl
找一個地方塞下這段程式碼:

代碼: 選擇全部

<SCRIPT Language="JavaScript"> 
//Pre-load your image below! 
grphcs=new Array(6) 
Image0=new Image(); 
Image0.src=grphcs[0]="d-254.gif";  //指定這個特效所用的圖片 
Image1=new Image(); 
Image1.src=grphcs[1]="d-254.gif"  //指定這個特效所用的圖片 
Image2=new Image(); 
Image2.src=grphcs[2]="d-266.gif"  //指定這個特效所用的圖片 
Image3=new Image(); 
Image3.src=grphcs[3]="d-266.gif"  //指定這個特效所用的圖片 
Image4=new Image(); 
Image4.src=grphcs[4]="d-254.gif"  //指定這個特效所用的圖片 
Image5=new Image(); 
Image5.src=grphcs[5]="d-266.gif"  //指定這個特效所用的圖片 

Amount=4; //Smoothness depends on image file size, the smaller the size the more you can use! 
Ypos=new Array(); 
Xpos=new Array(); 
Speed=new Array(); 
Step=new Array(); 
Cstep=new Array(); 
ns=(document.layers)?1:0; 
ns6=(document.getElementById&&!document.all)?1:0; 

if (ns){ 
for (i = 0; i < Amount; i++){ 
var P=Math.floor(Math.random()*grphcs.length); 
rndPic=grphcs[P]; 
document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0><img src="+rndPic+"></LAYER>"); 
} 
} 
else{ 
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">'); 
for (i = 0; i < Amount; i++){ 
var P=Math.floor(Math.random()*grphcs.length); 
rndPic=grphcs[P]; 
document.write('<img id="si'+i+'" src="'+rndPic+'" style="position:absolute;top:0px;left:0px">'); 
} 
document.write('</div></div>'); 
} 
WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight; 
WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth; 
for (i=0; i < Amount; i++){ 
 Ypos[i] = Math.round(Math.random()*WinHeight); 
 Xpos[i] = Math.round(Math.random()*WinWidth); 
 Speed[i]= Math.random()*5+3; 
 Cstep[i]=0; 
 Step[i]=Math.random()*0.1+0.05; 
} 
function fall(){ 
var WinHeight=(ns||ns6)?window.innerHeight:window.document.body.clientHeight; 
var WinWidth=(ns||ns6)?window.innerWidth-70:window.document.body.clientWidth; 
var hscrll=(ns||ns6)?window.pageYOffset:document.body.scrollTop; 
var wscrll=(ns||ns6)?window.pageXOffset:document.body.scrollLeft; 
for (i=0; i < Amount; i++){ 
sy = Speed[i]*Math.sin(90*Math.PI/180); 
sx = Speed[i]*Math.cos(Cstep[i]); 
Ypos[i]+=sy; 
Xpos[i]+=sx; 
if (Ypos[i] > WinHeight){ 
Ypos[i]=-60; 
Xpos[i]=Math.round(Math.random()*WinWidth); 
Speed[i]=Math.random()*5+3; 
} 
if (ns){ 
document.layers['sn'+i].left=Xpos[i]; 
document.layers['sn'+i].top=Ypos[i]+hscrll; 
} 
else if (ns6){ 
document.getElementById("si"+i).style.left=Math.min(WinWidth,Xpos[i]); 
document.getElementById("si"+i).style.top=Ypos[i]+hscrll; 
} 
else{ 
eval("document.all.si"+i).style.left=Xpos[i]; 
eval("document.all.si"+i).style.top=Ypos[i]+hscrll; 
} 
Cstep[i]+=Step[i]; 
} 
setTimeout('fall()',10); 
} 

window.onload=fall 
</SCRIPT>  
最後由 雪曼 於 2005-10-23 16:59 編輯,總共編輯了 1 次。
竹貓點擊率最高的連結---->
w2812451
星球公民
星球公民
文章: 255
註冊時間: 2005-07-16 21:38

文章 w2812451 »

setTimeout('fall()',10);
10改成你要的速度!數字越大速度越慢,速字小則相反!

建議不要使用這個東西!ˊˋ看久頭會暈~
故天將降大任於是人也,必先苦其心志,勞其筋骨,餓其體膚,空乏其身,行拂亂其所為,所以動心忍性,曾益其所不能。然後知生於憂患而死於安樂也。
☆╮¥藍 天 星 雨£╭★
ghostfbnm
星球公民
星球公民
文章: 75
註冊時間: 2005-03-12 22:47
來自: 台中
聯繫:

文章 ghostfbnm »

標題應該打成 javascript 的問題才對。
目前在學3D模組製作,努力加油中 . . .
主題已鎖定

回到「外掛問題討論」