本文整理汇总了Java中com.badlogic.gdx.utils.SnapshotArray.begin方法的典型用法代码示例。如果您正苦于以下问题:Java SnapshotArray.begin方法的具体用法?Java SnapshotArray.begin怎么用?Java SnapshotArray.begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.SnapshotArray
的用法示例。
在下文中一共展示了SnapshotArray.begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: 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);
}
}
示例4: setChangedFlagToAllItems
import com.badlogic.gdx.utils.SnapshotArray; //导入方法依赖的package包/类
private void setChangedFlagToAllItems() {
if (listView == null || ON_LAYOUT_WORK.get()) return;
SnapshotArray<ListViewItem> allItems = listView.items();
Object[] actors = allItems.begin();
for (int i = 0, n = allItems.size; i < n; i++) {
CacheListItem item = (CacheListItem) actors[i];
item.posOrBearingChanged();
}
allItems.end();
CB.requestRendering();
}
示例5: dispatch
import com.badlogic.gdx.utils.SnapshotArray; //导入方法依赖的package包/类
public <T> void dispatch(EventType<T> type, T t) {
SnapshotArray<EventListener<T>> list = getList(type, false);
if (list == null)
return;
EventListener<T>[] items = list.begin();
for (int i = 0, n = list.size; i < n; i++) {
items[i].handle(type, t);
}
list.end();
}
示例6: cancelTouchFocus
import com.badlogic.gdx.utils.SnapshotArray; //导入方法依赖的package包/类
/** Cancels touch focus for the specified actor.
* @see #cancelTouchFocus() */
public void cancelTouchFocus (Actor actor) {
InputEvent event = Pools.obtain(InputEvent.class);
event.setStage(this);
event.setType(InputEvent.Type.touchUp);
event.setStageX(Integer.MIN_VALUE);
event.setStageY(Integer.MIN_VALUE);
// Cancel all current touch focuses for the specified listener, allowing for concurrent modification, and never cancel the
// same focus twice.
SnapshotArray<TouchFocus> touchFocuses = this.touchFocuses;
TouchFocus[] items = touchFocuses.begin();
for (int i = 0, n = touchFocuses.size; i < n; i++) {
TouchFocus focus = items[i];
if (focus.listenerActor != actor) continue;
if (!touchFocuses.removeValue(focus, true)) continue; // Touch focus already gone.
event.setTarget(focus.target);
event.setListenerActor(focus.listenerActor);
event.setPointer(focus.pointer);
event.setButton(focus.button);
focus.listener.handle(event);
// Cannot return TouchFocus to pool, as it may still be in use (eg if cancelTouchFocus is called from touchDragged).
}
touchFocuses.end();
Pools.free(event);
}
示例7: cancelTouchFocusExcept
import com.badlogic.gdx.utils.SnapshotArray; //导入方法依赖的package包/类
/** Cancels touch focus for all listeners except the specified listener.
* @see #cancelTouchFocus() */
public void cancelTouchFocusExcept (EventListener exceptListener, Actor exceptActor) {
InputEvent event = Pools.obtain(InputEvent.class);
event.setStage(this);
event.setType(InputEvent.Type.touchUp);
event.setStageX(Integer.MIN_VALUE);
event.setStageY(Integer.MIN_VALUE);
// Cancel all current touch focuses except for the specified listener, allowing for concurrent modification, and never
// cancel the same focus twice.
SnapshotArray<TouchFocus> touchFocuses = this.touchFocuses;
TouchFocus[] items = touchFocuses.begin();
for (int i = 0, n = touchFocuses.size; i < n; i++) {
TouchFocus focus = items[i];
if (focus.listener == exceptListener && focus.listenerActor == exceptActor) continue;
if (!touchFocuses.removeValue(focus, true)) continue; // Touch focus already gone.
event.setTarget(focus.target);
event.setListenerActor(focus.listenerActor);
event.setPointer(focus.pointer);
event.setButton(focus.button);
focus.listener.handle(event);
// Cannot return TouchFocus to pool, as it may still be in use (eg if cancelTouchFocus is called from touchDragged).
}
touchFocuses.end();
Pools.free(event);
}
示例8: notifyFamilyListenersAdd
import com.badlogic.gdx.utils.SnapshotArray; //导入方法依赖的package包/类
private void notifyFamilyListenersAdd(Family family, Entity entity) {
SnapshotArray<EntityListener> listeners = familyListeners.get(family);
if (listeners != null) {
Object[] items = listeners.begin();
for (int i = 0, n = listeners.size; i < n; i++) {
EntityListener listener = (EntityListener) items[i];
listener.entityAdded(entity);
}
listeners.end();
}
}
示例9: notifyFamilyListenersRemove
import com.badlogic.gdx.utils.SnapshotArray; //导入方法依赖的package包/类
private void notifyFamilyListenersRemove(Family family, Entity entity) {
SnapshotArray<EntityListener> listeners = familyListeners.get(family);
if (listeners != null) {
Object[] items = listeners.begin();
for (int i = 0, n = listeners.size; i < n; i++) {
EntityListener listener = (EntityListener) items[i];
listener.entityRemoved(entity);
}
listeners.end();
}
}
示例10: getObject
import com.badlogic.gdx.utils.SnapshotArray; //导入方法依赖的package包/类
public Actor3d getObject(int screenX, int screenY) {
Actor3d temp = null;
SnapshotArray<Actor3d> children = root.getChildren();
Actor3d[] actors = children.begin();
for(int i = 0, n = children.size; i < n; i++){
temp = hit3d(screenX, screenY, actors[i]);
if(actors[i] instanceof Group3d)
temp = hit3d(screenX, screenY, (Group3d)actors[i]);
}
children.end();
return temp;
}
示例11: hit3d
import com.badlogic.gdx.utils.SnapshotArray; //导入方法依赖的package包/类
public Actor3d hit3d(int screenX, int screenY, Group3d group3d) {
Actor3d temp = null;
SnapshotArray<Actor3d> children = group3d.getChildren();
Actor3d[] actors = children.begin();
for(int i = 0, n = children.size; i < n; i++){
temp = hit3d(screenX, screenY, actors[i]);
if(actors[i] instanceof Group3d)
temp = hit3d(screenX, screenY, (Group3d)actors[i]);
}
children.end();
return temp;
}
示例12: clearLayer
import com.badlogic.gdx.utils.SnapshotArray; //导入方法依赖的package包/类
@Override
public void clearLayer(Layer layer, boolean clearChildrenLayers) {
EngineEntity layerEntity = layers.get(layer);
SnapshotArray<Actor> childrenArray = layerEntity.getGroup()
.getChildren();
Actor[] children = childrenArray.begin();
for (int i = 0, n = childrenArray.size; i < n; i++) {
Actor actor = children[i];
if (actor.getUserObject() instanceof EngineLayer) {
if (clearChildrenLayers) {
EngineLayer childrenLayer = (EngineLayer) actor
.getUserObject();
clearLayer(getLayerForEntity(childrenLayer), true);
}
} else if (actor.getUserObject() instanceof EngineEntity) {
EngineEntity childEntityToRemove = (EngineEntity) actor
.getUserObject();
gameLoop.removeEntity(childEntityToRemove);
} else {
Gdx.app.error(
"GameView",
"GameView has a child that does not belong to an EngineEntity or its user object is not set.");
}
}
childrenArray.end();
}
示例13: doProcessEntity
import com.badlogic.gdx.utils.SnapshotArray; //导入方法依赖的package包/类
@Override
public void doProcessEntity(Entity entity, float deltaTime) {
Polygon polygon1 = BoundingAreaBuilder
.getBoundingPolygon((EngineEntity) entity);
CollisionComponent collisionComponent = entity
.getComponent(CollisionComponent.class);
SnapshotArray<RuntimeCollision> runtimeCollisions = collisionComponent
.getBehaviors();
Object[] runtimes = runtimeCollisions.begin();
for (int i = 0; i < runtimeCollisions.size; i++) {
RuntimeCollision runtime = (RuntimeCollision) runtimes[i];
runtime.updateTargets(variablesManager);
runtime.updateBoundingAreas(gameLoop);
for (EngineEntity potentialTarget : runtime.getPotentialTargets()) {
Polygon polygon2 = BoundingAreaBuilder
.getBoundingPolygon(potentialTarget);
if (Intersector.overlapConvexPolygons(polygon1, polygon2)) {
ChangeVar targetEntity = new ChangeVar();
targetEntity.setContext(ChangeVar.Context.LOCAL);
targetEntity.setExpression("(fromid s"
+ potentialTarget.getId() + ")");
targetEntity
.setVariable(ReservedVariableNames.COLLISION_TARGET);
Array<Effect> additionalEffect = new Array<Effect>();
additionalEffect.add(targetEntity);
addEffects(entity, additionalEffect);
addEffects(entity, runtime.getEffects());
break;
}
}
}
runtimeCollisions.end();
}
示例14: touchDragged
import com.badlogic.gdx.utils.SnapshotArray; //导入方法依赖的package包/类
public boolean touchDragged(int paramInt1, int paramInt2, int paramInt3)
{
int i = 0;
if (this.touchFocuses.size == 0)
return false;
screenToStageCoordinates(this.stageCoords.set(paramInt1, paramInt2));
InputEvent localInputEvent = (InputEvent)Pools.obtain(InputEvent.class);
localInputEvent.setType(InputEvent.Type.touchDragged);
localInputEvent.setStage(this);
localInputEvent.setStageX(this.stageCoords.x);
localInputEvent.setStageY(this.stageCoords.y);
localInputEvent.setPointer(paramInt3);
SnapshotArray localSnapshotArray = this.touchFocuses;
Stage.TouchFocus[] arrayOfTouchFocus = (Stage.TouchFocus[])localSnapshotArray.begin();
int j = localSnapshotArray.size;
while (i < j)
{
Stage.TouchFocus localTouchFocus = arrayOfTouchFocus[i];
if (localTouchFocus.pointer == paramInt3)
{
localInputEvent.setTarget(localTouchFocus.target);
localInputEvent.setListenerActor(localTouchFocus.listenerActor);
if (localTouchFocus.listener.handle(localInputEvent))
localInputEvent.handle();
}
i++;
}
localSnapshotArray.end();
boolean bool = localInputEvent.isHandled();
Pools.free(localInputEvent);
return bool;
}
示例15: drawChildren
import com.badlogic.gdx.utils.SnapshotArray; //导入方法依赖的package包/类
public void drawChildren(ModelBatch modelBatch, Environment environment){
//modelBatch.render(children, environment); maybe faster
SnapshotArray<Actor3d> children = this.children;
Actor3d[] actors = children.begin();
visibleCount = 0;
for (int i = 0, n = children.size; i < n; i++){
if(actors[i] instanceof Group3d){
((Group3d) actors[i]).drawChildren(modelBatch, environment);
}
else{
float offsetX = x, offsetY = y, offsetZ = z;
float offsetScaleX = scaleX, offsetScaleY = scaleY, offsetScaleZ = scaleZ;
float offsetYaw = yaw, offsetPitch = pitch, offsetRoll = roll;
x = 0;
y = 0;
z = 0;
scaleX = 0;
scaleY = 0;
scaleZ = 0;
yaw = 0;
pitch = 0;
roll = 0;
Actor3d child = actors[i];
if (!child.isVisible()) continue;
/*Matrix4 diff = sub(child.getTransform(), getTransform());
Matrix4 childMatrix = child.getTransform().cpy();
child.getTransform().set(add(diff, childMatrix));
child.draw(modelBatch, environment);*/
float cx = child.x, cy = child.y, cz = child.z;
float sx = child.scaleX, sy = child.scaleY, sz = child.scaleZ;
float ry = child.yaw, rp = child.pitch, rr = child.roll;
//child.x = cx + offsetX;
//child.y = cy + offsetY;
//child.z = cz + offsetZ;
child.setPosition(cx + offsetX, cy + offsetY, cz + offsetZ);
child.setScale(sx + offsetScaleX, sy + offsetScaleY, sz + offsetScaleZ);
child.setRotation(ry + offsetYaw, rp + offsetPitch, rr +offsetRoll);
if (child.isCullable(getStage3d().getCamera())) {
child.draw(modelBatch, environment);
visibleCount++;
}
child.x = cx;
child.y = cy;
child.z = cz;
x = offsetX;
y = offsetY;
z = offsetZ;
child.scaleX = sx;
child.scaleY = sy;
child.scaleZ = sz;
scaleX = offsetScaleX;
scaleY = offsetScaleY;
scaleZ = offsetScaleZ;
child.yaw = ry;
child.pitch = rp;
child.roll = rr;
yaw = offsetYaw;
pitch = offsetPitch;
roll = offsetRoll;
}
}
children.end();
}