我正在尝试创建一个立方体循环并将 ColorMaterial 应用于表面。主要的 actionscript 类具有以下用于创建循环的方法。有一个名为 Building 的外部类文件负责形状和 ColorMaterial。不幸的是,我似乎做错了什么。Flash Builder 未显示任何警告或错误。但是当我运行测试时,我得到的只是黑屏。
private function buildCity():void
{
var citySize:int = 1800;
var buildingSize:int = 100;
var roadSize:int = 50;
// Loop across in the x direction and again in the z direction
for(var cityX:int=citySize/2;cityX<citySize/2;cityX+=buildingSize+roadSize)
{
for(var cityZ:int=citySize/2;cityZ<citySize/2;cityZ+=buildingSize+roadSize)
{
// Create buildings
var building:Building = new Building();
// Position it
building.x = cityX;
building.z = cityZ;
// Add to the scene
view.scene.addChild(building);
}
}
}
负责形状和材料的建筑类
package
{
import away3d.entities.Mesh;
import away3d.materials.ColorMaterial;
import away3d.primitives.CubeGeometry;
public class Building extends Mesh
{
public function Building()
{
super(new CubeGeometry(50,100,50));
// Make a material
material = new ColorMaterial(Math.random()*0xFFFFFF);
// Offset the y position based on height
y = 50;
}
}
}