6
有沒有更好的方法來做到這一點?我覺得自己因爲太重複而做錯了事。有沒有更好的方法來寫這個?
O = viz.pick(1, viz.WORLD)
BackSetts = ["set_b1b", "set_b2a", "set_b1a", "set_b2b"]
LeftSetts = ["set_l1a", "set_l1b", "set_l2a", "set_l1b"]
NormSetts = ["set_nr_a", "set_nr_b"]
Maps = ["MapA","MapB"]
if O.name in BackSetts:
for i in set(BackSetts)|set(Maps):
WORLD[i].alpha(abs(WORLD[i].getAlpha()-1))
elif O.name in LeftSetts:
for i in set(LeftSetts)|set(Maps):
WORLD[i].alpha(abs(WORLD[i].getAlpha()-1))
elif O.name in NormSetts:
for i in NormSetts:
WORLD[i].alpha(abs(WORLD[i].getAlpha()-1))
你想做什麼? – katrielalex 2010-10-28 22:35:49
這段代碼告訴我的3D引擎(類似於panda3d),當鼠標點擊一個開關對象(viz.pick)時,檢查哪些「地圖」可見(alpha)作爲我的多邊形上的紋理;它顛倒了應用紋理的透明狀態。 – relima 2010-10-28 23:11:14