Re: [問題] 數學不好的煩腦, 排列檢定.

看板Flash作者 (我愛Hot_game板)時間17年前 (2008/03/15 20:26), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串4/5 (看更多)
※ 引述《babyfaker (oooo)》之銘言: : 請問各位一個問題. : 假設總共有九張圖片,排列會隨著stage的寬度自動換行的數學式如何寫呢? : 假設一張圖寬度為300 : stage寬度為2700 : P P P P P P P P P : 當stage寬度變為900時自動換為. : P P P : P P P : P P P : 謝謝~~ T_T 我也來參一腳XDD (用AS3) 設圖片名稱pic0,pic1,...etc, 圖片寬picWidth,高picHeight,共有N張圖片: var int:availableWidth = stage.stageWidth/picWidth; for ( var i:int=0; i<N; i++ ){ this["pic" + i].y = Math.floor(i / availableWidth)*picHeight; this["pic" + i].x = (i % availableWidth)*picWidth; } (int會無條件捨去小數點,大概和Math.floor一樣) 如果要改基準點的話,就在x和y各加個數字就行了 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.70.112.35 ※ 編輯: Jerrynet 來自: 219.70.112.35 (03/15 20:30)
文章代碼(AID): #17sy1P9S (Flash)
文章代碼(AID): #17sy1P9S (Flash)