本文整理汇总了Java中com.badlogic.gdx.utils.Array.random方法的典型用法代码示例。如果您正苦于以下问题:Java Array.random方法的具体用法?Java Array.random怎么用?Java Array.random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.Array
的用法示例。
在下文中一共展示了Array.random方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createRing
import com.badlogic.gdx.utils.Array; //导入方法依赖的package包/类
public Ring createRing(Ring ring) {
Array<ColorGroup> colors = new Array<ColorGroup>();
colors.add(new ColorGroup()
.add(Color.rgba8888(223f / 255f, 233f / 255f, 180f / 255f, 1f))
.add(Color.rgba8888(170f / 255f, 90f / 255f, 103f / 255f, 1f)));
colors.add(new ColorGroup()
.add(Color.rgba8888(191f / 255f, 231f / 255f, 231f / 255f, 1f))
.add(Color.rgba8888(75f / 255f, 109f / 255f, 133f / 255f, 1f)));
colors.add(new ColorGroup()
.add(Color.rgba8888(169f / 255f, 194f / 255f, 175f / 255f, 1f))
.add(Color.rgba8888(30f / 255f, 97f / 255f, 42f / 255f, 1f)));
Ring innerRing = ring != null ? ring : previousRing;
int objectCount = innerRing == null ? MathUtils.random(200, 300) : MathUtils.random(200, 350);
float angularVelocity = 0;
float zTilt = innerRing == null ? 30 : innerRing.getZTilt();
float xTilt = innerRing == null ? -20 : innerRing.getXTilt();
float minimumRadius = innerRing == null ? scene.getPlanet().getWidthAtY(0) + 25 : innerRing.getMaximumRadius() + 5;
float maximumRadius = innerRing == null ? minimumRadius + MathUtils.random(20, 60) : minimumRadius + MathUtils.random(20, 50);
ColorGroup colorGroup = colors.random();
Array<Orbiter> ringObjects = new Array<>();
for(int i = 0; i < objectCount; i++) {
Orbiter.OrbiterBlueprint blueprint = new Orbiter.OrbiterBlueprint();
blueprint.angularVelocity = angularVelocity;
blueprint.zTilt = zTilt;
blueprint.xTilt = xTilt;
blueprint.angle = MathUtils.random(0, 360);
blueprint.radius = MathUtils.random(minimumRadius, maximumRadius);
Orbiter ringObject = null;
if (MathUtils.randomBoolean(0.9f)) {
ringObject = new Orbiter(createMoonSprite(MathUtils.random(4, 6)), blueprint, colorGroup.random());
} else {
ringObject = new Orbiter(createSquare(MathUtils.random(4, 5)), blueprint, colorGroup.random());
}
ringObjects.add(ringObject);
}
//scene.addSpaceObjects(ringObjects);
Ring newRing = new Ring(ringObjects, colorGroup, minimumRadius, maximumRadius);
scene.addRing(newRing);
return newRing;
}