作者Jerrynet (我爱Hot_game板)
看板Flash
标题Re: [问题] 数学不好的烦脑, 排列检定.
时间Sat Mar 15 20:25:59 2008
※ 引述《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)