本文整理汇总了Java中com.badlogic.gdx.utils.SnapshotArray类的典型用法代码示例。如果您正苦于以下问题:Java SnapshotArray类的具体用法?Java SnapshotArray怎么用?Java SnapshotArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SnapshotArray类属于com.badlogic.gdx.utils包,在下文中一共展示了SnapshotArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: markPlayerAsReady
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
/**
* Visually indicate that a player has been marked as ready.
*
* @param username username of the ready player
*/
private void markPlayerAsReady(String username) {
// Find the table row containing the player that has been marked as ready
final SnapshotArray<Actor> children = playersTable.getChildren();
// Ignore the first child since it's just the table header
for (int i = 1; i < children.size; i++) {
Actor actor = children.get(i);
if (actor instanceof Table) {
final Actor label = ((Table) actor).getCells().get(0).getActor();
if (label instanceof Label) {
if (((Label) label).getText().toString().equals(username)) {
((Table) actor).setBackground("readyBackground");
break;
}
}
}
}
}
示例2: removePlayer
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
/**
* Remove a player from the list of players as a result of him/her leaving
* the game.
*
* @param username username of the player
*/
private void removePlayer(String username) {
Table playerTable = null;
// Find the table row containing the player that left the game
final SnapshotArray<Actor> children = playersTable.getChildren();
// Ignore the first child since it's just the table header
for (int i = 1; i < children.size; i++) {
Actor actor = children.get(i);
if (actor instanceof Table) {
final Actor label = ((Table) actor).getCells().get(0).getActor();
if (label instanceof Label) {
if (((Label) label).getText().toString().equals(username)) {
playerTable = ((Table) actor);
break;
}
}
}
}
if (playerTable != null)
playersTable.removeActor(playerTable);
}
示例3: hit
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
@Override
public Actor hit(float x, float y, boolean touchable) {
//Still include menu button
tempVector.set(x, y);
localToStageCoordinates(tempVector);
closeButton.stageToLocalCoordinates(tempVector);
if (closeButton.hit(tempVector.x, tempVector.y, touchable) != null)
return closeButton.hit(tempVector.x, tempVector.y, touchable);
//Find deepest child at position
SnapshotArray<Actor> childrenSnapshot = getChildren();
Actor[] children = childrenSnapshot.items;
for(int i = childrenSnapshot.size - 1; i >= 0; i--) {
Actor child = children[i];
child.parentToLocalCoordinates(tempVector.set(x, y));
if (child.hit(tempVector.x, tempVector.y, touchable) != null)
return child;
}
return this;
}
示例4: resizeElements
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
protected void resizeElements() {
Vector2 screenSize = new Vector2(getWidth(), getHeight());
if(menuBar != null) {
screenSize.y -= menuBar.getTable().getHeight();
menuBar.getTable().pack();
menuBar.getTable().setPosition(0, screenSize.y);
menuBar.getTable().setWidth(screenSize.x);
}
Table table = tabControl.getTable();
table.setSize(screenSize.x, 24);
table.setPosition(0, screenSize.y-table.getHeight());
activePane.setBounds(0, 0, screenSize.x, screenSize.y-table.getHeight());
SnapshotArray<Actor> paneChildren = activePane.getChildren();
if(paneChildren.size >= 1) {
paneChildren.first().setBounds(0, 0, activePane.getWidth(), activePane.getHeight());
}
}
示例5: resizeElements
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
@Override
protected void resizeElements() {
if(scroller != null) {
scroller.setBounds(0, 0, getWidth()*0.15f, getHeight());
scroller.setScrollBarPositions(true, true);
}
if(objList != null) {
objList.pack();
objList.setPosition(0, 0);
objList.setWidth(scroller.getWidth()-30);
}
Table table = tabControl.getTable();
table.setSize(getWidth()*0.85f, 24);
table.setPosition(getWidth()*0.15f, getHeight()-table.getHeight());
activePane.setBounds(getWidth()*0.15f, 0, getWidth()*0.85f, getHeight()-table.getHeight());
SnapshotArray<Actor> paneChildren = activePane.getChildren();
if(paneChildren.size >= 1) {
paneChildren.first().setBounds(0, 0, activePane.getWidth(), activePane.getHeight());
}
}
示例6: getValue
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
Coordinate getValue() {
StringBuilder sb = new StringBuilder();
SnapshotArray<Actor> childs = this.getChildren();
for (Actor actor : childs) {
if (actor == null) {
sb.append(" ");
} else {
if (actor instanceof VisTextButton) {
sb.append(((VisTextButton) actor).getText());
} else if (actor instanceof VisLabel) {
sb.append(((VisLabel) actor).getText());
}
}
}
return new Coordinate(sb.toString());
}
示例7: onShow
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
public void onShow() {
SnapshotArray<Actor> childs = this.getChildren();
if (childs != null && childs.size > 0) {
try {
for (int i = 0, n = childs.size; i < n; i++) {
// alle renderChilds() der in dieser CB_View_Base
// enthaltenen Childs auf rufen.
if (childs.get(i) instanceof CB_View_Base) {
CB_View_Base view = (CB_View_Base) childs.get(i);
if (view != null)
view.onShow();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例8: onHide
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
public void onHide() {
SnapshotArray<Actor> childs = this.getChildren();
if (childs != null && childs.size > 0) {
try {
for (int i = 0, n = childs.size; i < n; i++) {
// alle renderChilds() der in dieser GL_View_Base
// enthaltenen Childs auf rufen.
if (childs.get(i) instanceof CB_View_Base) {
CB_View_Base view = (CB_View_Base) childs.get(i);
if (view != null)
view.onHide();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例9: nextView
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
public void nextView() {
Gdx.app.debug("PageView", "Change to next view");
SnapshotArray<Actor> children = this.getChildren();
if (children.get(children.size - 1).getX() <= 0) {
Gdx.app.debug("PageView", "Already last one, can't move to next.");
return;
}
Actor[] actors = children.begin();
float width = this.getWidth();
for (Actor actor : actors) {
if (actor != null) {
actor.addAction(Actions.moveTo(actor.getX() - width, 0, 0.5f));
}
}
children.end();
}
示例10: previousView
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
public void previousView() {
Gdx.app.debug("PageView", "Change to previous view");
SnapshotArray<Actor> children = this.getChildren();
if (children.get(0).getX() >= 0) {
Gdx.app.debug("PageView", "Already first one, can't move to previous.");
return;
}
float width = this.getWidth();
Actor[] actors = children.begin();
for (Actor actor : actors) {
if (actor != null) {
actor.addAction(Actions.moveTo(actor.getX() + width, 0, 0.5f));
}
}
children.end();
}
示例11: computeSize
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
private void computeSize() {
sizeInvalid = false;
maxWidth = minWidth = prefWidth = getStage().getWidth() - 5;
maxHeight = minHeight = prefHeight = 0;
SnapshotArray<Actor> children = getChildren();
for (int i = 0, n = children.size; i < n; i++) {
Actor child = children.get(i);
if (!child.isVisible()) {
continue;
}
if (child instanceof Layout) {
Layout layout = (Layout) child;
prefHeight += layout.getPrefHeight();
minHeight += layout.getMinHeight();
} else {
prefHeight += child.getHeight();
minHeight += child.getHeight();
}
}
}
示例12: computeSize
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
private void computeSize () {
sizeInvalid = false;
SnapshotArray<Actor> children = getChildren();
int n = children.size;
prefWidth = 0;
prefHeight = padTop + padBottom + spacing * (n - 1);
for (int i = 0; i < n; i++) {
Actor child = children.get(i);
if (child instanceof Layout) {
Layout layout = (Layout)child;
prefWidth = Math.max(prefWidth, layout.getPrefWidth());
prefHeight += layout.getPrefHeight();
} else {
prefWidth = Math.max(prefWidth, child.getWidth());
prefHeight += child.getHeight();
}
}
prefWidth += padLeft + padRight;
if (round) {
prefWidth = Math.round(prefWidth);
prefHeight = Math.round(prefHeight);
}
}
示例13: computeSize
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
private void computeSize () {
sizeInvalid = false;
SnapshotArray<Actor> children = getChildren();
int n = children.size;
prefWidth = padLeft + padRight + spacing * (n - 1);
prefHeight = 0;
for (int i = 0; i < n; i++) {
Actor child = children.get(i);
if (child instanceof Layout) {
Layout layout = (Layout)child;
prefWidth += layout.getPrefWidth();
prefHeight = Math.max(prefHeight, layout.getPrefHeight());
} else {
prefWidth += child.getWidth();
prefHeight = Math.max(prefHeight, child.getHeight());
}
}
prefHeight += padTop + padBottom;
if (round) {
prefWidth = Math.round(prefWidth);
prefHeight = Math.round(prefHeight);
}
}
示例14: setProperty
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void setProperty(String name, String value) {
SnapshotArray<Actor> actors = table.getChildren();
for (Actor a : actors) {
if (name.equals(a.getName())) {
if (a instanceof SelectBox<?>) {
((SelectBox<String>) a).setSelected(value == null ? "" : value);
} else {
((TextField) a).setText(value == null ? "" : value);
}
return;
}
}
}
示例15: doProcessEntity
import com.badlogic.gdx.utils.SnapshotArray; //导入依赖的package包/类
@Override
public void doProcessEntity(Entity entity, float delta) {
TimersComponent timers = entity.getComponent(TimersComponent.class);
SnapshotArray<RuntimeTimer> timerList = timers.getBehaviors();
Object[] timerArray = timerList.begin();
for (int j = 0, n = timerList.size; j < n; j++) {
RuntimeTimer timer = (RuntimeTimer) timerArray[j];
if (!evaluateCondition(timer.getCondition()))
continue;
int count = timer.update(delta);
for (int i = 0; i < count; i++) {
addEffects(entity, timer.getEffects());
}
if (timer.isDone()) {
timerList.removeValue(timer, true);
}
}
timerList.end();
// If no timers remaining, remove the component
if (timers.getBehaviors().size == 0) {
entity.remove(TimersComponent.class);
}
}