Java Code Examples for com.badlogic.gdx.utils.SnapshotArray#end()

The following examples show how to use com.badlogic.gdx.utils.SnapshotArray#end() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PageView.java    From cocos-ui-libgdx with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 2
Source File: PageView.java    From cocos-ui-libgdx with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 3
Source File: EventDispatcher.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
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();
}
 
Example 4
Source File: BeltGrid.java    From riiablo with Apache License 2.0 5 votes vote down vote up
private void updateItems(boolean hidden) {
  Touchable touchable = hidden ? Touchable.disabled : Touchable.enabled;
  SnapshotArray<Actor> snapshot = getChildren();
  Actor[] children = snapshot.begin();
  for (Actor child : children) {
    StoredItem item = (StoredItem) child;
    if (item == null) continue;
    if (item.getY() >= boxHeight) item.setTouchable(touchable);
  }
  snapshot.end();
}
 
Example 5
Source File: Stage3d.java    From Scene3d with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 6
Source File: Stage3d.java    From Scene3d with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 7
Source File: Group3d.java    From Scene3d with Apache License 2.0 4 votes vote down vote up
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();
}