本文整理了Java中com.badlogic.gdx.utils.Array.first()
方法的一些代码示例,展示了Array.first()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Array.first()
方法的具体详情如下:
包路径:com.badlogic.gdx.utils.Array
类名称:Array
方法名:first
[英]Returns the first item.
[中]返回第一项。
代码示例来源:origin: libgdx/libgdx
/** Returns the first texture region. This is included for backwards compatibility, and for convenience since most fonts only
* use one texture page. For multi-page fonts, use {@link #getRegions()}.
* @return the first texture region */
public TextureRegion getRegion () {
return regions.first();
}
代码示例来源:origin: libgdx/libgdx
/** Returns the first texture region. This is included for backwards compatibility, and for convenience since most fonts only
* use one texture page. For multi-page fonts, use {@link #getRegions()}.
* @return the first texture region */
public TextureRegion getRegion () {
return regions.first();
}
代码示例来源:origin: libgdx/libgdx
/** Convenience method to return the first Texture attachment present in the fbo **/
public T getColorBufferTexture () {
return textureAttachments.first();
}
代码示例来源:origin: libgdx/libgdx
/** Convenience method to return the first Texture attachment present in the fbo **/
public T getColorBufferTexture () {
return textureAttachments.first();
}
代码示例来源:origin: libgdx/libgdx
@Override
public void init () {
Model first = models.first();
for (int i = 0, c = controller.emitter.maxParticleCount; i < c; ++i) {
modelChannel.data[i] = new ModelInstance(first);
}
}
代码示例来源:origin: libgdx/libgdx
@Override
public void init () {
Model first = models.first();
for (int i = 0, c = controller.emitter.maxParticleCount; i < c; ++i) {
modelChannel.data[i] = new ModelInstance(first);
}
}
代码示例来源:origin: libgdx/libgdx
@Override
public void init () {
ParticleController first = templates.first();
for (int i = 0, c = controller.particles.capacity; i < c; ++i) {
ParticleController copy = first.copy();
copy.init();
particleControllerChannel.data[i] = copy;
}
}
代码示例来源:origin: libgdx/libgdx
@Override
public void init () {
ParticleController first = templates.first();
for (int i = 0, c = controller.particles.capacity; i < c; ++i) {
ParticleController copy = first.copy();
copy.init();
particleControllerChannel.data[i] = copy;
}
}
代码示例来源:origin: libgdx/libgdx
/** Removes objects from the selection that are no longer in the items array. If {@link #getRequired()} is true and there is no
* selected item, the first item is selected. */
public void validate () {
Array<T> array = this.array;
if (array.size == 0) {
clear();
return;
}
for (Iterator<T> iter = items().iterator(); iter.hasNext();) {
T selected = iter.next();
if (!array.contains(selected, false)) iter.remove();
}
if (required && selected.size == 0) set(array.first());
}
}
代码示例来源:origin: libgdx/libgdx
/** Removes objects from the selection that are no longer in the items array. If {@link #getRequired()} is true and there is no
* selected item, the first item is selected. */
public void validate () {
Array<T> array = this.array;
if (array.size == 0) {
clear();
return;
}
for (Iterator<T> iter = items().iterator(); iter.hasNext();) {
T selected = iter.next();
if (!array.contains(selected, false)) iter.remove();
}
if (required && selected.size == 0) set(array.first());
}
}
代码示例来源:origin: libgdx/libgdx
/** Sets the selection to only the passed item, if it is a possible choice, else selects the first item. */
public void setSelected (T item) {
if (items.contains(item, false))
selection.set(item);
else if (items.size > 0)
selection.set(items.first());
else
selection.clear();
}
代码示例来源:origin: libgdx/libgdx
@Override
public PolygonRegion load (AssetManager manager, String fileName, FileHandle file, PolygonRegionParameters parameter) {
Texture texture = manager.get(manager.getDependencies(fileName).first());
return load(new TextureRegion(texture), file);
}
代码示例来源:origin: libgdx/libgdx
@Override
public PolygonRegion load (AssetManager manager, String fileName, FileHandle file, PolygonRegionParameters parameter) {
Texture texture = manager.get(manager.getDependencies(fileName).first());
return load(new TextureRegion(texture), file);
}
代码示例来源:origin: libgdx/libgdx
/** Sets the selection to only the passed item, if it is a possible choice, else selects the first item. */
public void setSelected (T item) {
if (items.contains(item, false))
selection.set(item);
else if (items.size > 0)
selection.set(items.first());
else
selection.clear();
}
代码示例来源:origin: libgdx/libgdx
/** Sets the selection to only the passed item, if it is a possible choice.
* @param item May be null. */
public void setSelected (T item) {
if (items.contains(item, false))
selection.set(item);
else if (selection.getRequired() && items.size > 0)
selection.set(items.first());
else
selection.clear();
}
代码示例来源:origin: libgdx/libgdx
/** Sets the selection to only the passed item, if it is a possible choice.
* @param item May be null. */
public void setSelected (T item) {
if (items.contains(item, false))
selection.set(item);
else if (selection.getRequired() && items.size > 0)
selection.set(items.first());
else
selection.clear();
}
代码示例来源:origin: libgdx/libgdx
public void setSprites (Array<Sprite> sprites) {
this.sprites = sprites;
if (sprites.size == 0) return;
for (int i = 0, n = particles.length; i < n; i++) {
Particle particle = particles[i];
if (particle == null) break;
Sprite sprite = null;
switch (spriteMode) {
case single:
sprite = sprites.first();
break;
case random:
sprite = sprites.random();
break;
case animated:
float percent = 1 - particle.currentLife / (float)particle.life;
particle.frame = Math.min((int)(percent * sprites.size), sprites.size - 1);
sprite = sprites.get(particle.frame);
break;
}
particle.setRegion(sprite);
particle.setOrigin(sprite.getOriginX(), sprite.getOriginY());
}
}
代码示例来源:origin: libgdx/libgdx
public void setSprites (Array<Sprite> sprites) {
this.sprites = sprites;
if (sprites.size == 0) return;
for (int i = 0, n = particles.length; i < n; i++) {
Particle particle = particles[i];
if (particle == null) break;
Sprite sprite = null;
switch (spriteMode) {
case single:
sprite = sprites.first();
break;
case random:
sprite = sprites.random();
break;
case animated:
float percent = 1 - particle.currentLife / (float)particle.life;
particle.frame = Math.min((int)(percent * sprites.size), sprites.size - 1);
sprite = sprites.get(particle.frame);
break;
}
particle.setRegion(sprite);
particle.setOrigin(sprite.getOriginX(), sprite.getOriginY());
}
}
代码示例来源:origin: libgdx/libgdx
public void create () {
font = new BitmapFont();
font.setColor(0, 0, 0, 1);
Pixmap pixmap = new Pixmap(16, 16, Format.RGBA8888);
pixmap.setColor(1, 1, 1, 1);
pixmap.fill();
texture = new Texture(pixmap);
batch = new SpriteBatch();
camera = new OrthographicCamera();
camera.position.set(100, 100, 0);
camera.update();
viewports = ViewportTest1.getViewports(camera);
viewport = viewports.first();
names = ViewportTest1.getViewportNames();
name = names.first();
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean keyDown (int keycode) {
if (keycode == Input.Keys.SPACE) {
int index = (viewports.indexOf(viewport, true) + 1) % viewports.size;
name = names.get(index);
viewport = viewports.get(index);
resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
return false;
}
});
}
代码示例来源:origin: libgdx/libgdx
@Override
public void render() {
Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
batch.setProjectionMatrix(camera.combined);
batch.begin();
float x = 10;
float y = Gdx.graphics.getHeight() - 10;
int renderCalls = 0;
// NOTE: Before production release on mobile, you should cache the array from values()
// inside the Enum in order to reduce allocations in the render loop.
for (FontStyle style : FontStyle.values()) {
for (FontSize size : FontSize.values()) {
BitmapFont fnt = getFont(style, size);
fnt.draw(batch, style.name() + " " + size.size + "pt: The quick brown fox jumps over the lazy dog", x, y);
y -= fnt.getLineHeight() + 10;
}
y -= 20;
}
BitmapFont font = getFont(FontStyle.Regular, FontSize.Medium);
font.draw(batch, text, 10, font.getCapHeight() + 10);
// draw all glyphs in background
batch.setColor(1f, 1f, 1f, 0.15f);
batch.draw(packer.getPages().first().getTexture(), 0, 0);
batch.setColor(1f, 1f, 1f, 1f);
batch.end();
}
内容来源于网络,如有侵权,请联系作者删除!