本文整理匯總了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;
}