List of usage examples for com.badlogic.gdx.utils Array first
public T first()
From source file:com.badlogic.invaders.Invaders.java
License:Apache License
@Override public void create() { Array<Controller> controllers = Controllers.getControllers(); if (controllers.size > 0) { controller = controllers.first(); }// w w w. ja v a2s . c o m Controllers.addListener(controllerListener); setScreen(new MainMenu(this)); music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal)); music.setLooping(true); music.play(); Gdx.input.setInputProcessor(new InputAdapter() { @Override public boolean keyUp(int keycode) { if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) { if (!Gdx.graphics.isFullscreen()) Gdx.graphics.setDisplayMode(Gdx.graphics.getDisplayModes()[0]); } return true; } }); fps = new FPSLogger(); }
From source file:com.company.minery.utils.spine.Skeleton.java
License:Open Source License
/** Caches information about bones and IK constraints. Must be called if bones or IK constraints are added or removed. */ public void updateCache() { Array<Bone> bones = this.bones; Array<Array<Bone>> boneCache = this.boneCache; Array<IkConstraint> ikConstraints = this.ikConstraints; int ikConstraintsCount = ikConstraints.size; int arrayCount = ikConstraintsCount + 1; while (boneCache.size < arrayCount) boneCache.add(new Array()); for (int i = 0; i < arrayCount; i++) boneCache.get(i).clear();//w w w .j a v a2 s . c om Array<Bone> nonIkBones = boneCache.first(); outer: for (int i = 0, n = bones.size; i < n; i++) { Bone bone = bones.get(i); Bone current = bone; do { for (int ii = 0; ii < ikConstraintsCount; ii++) { IkConstraint ikConstraint = ikConstraints.get(ii); Bone parent = ikConstraint.bones.first(); Bone child = ikConstraint.bones.peek(); while (true) { if (current == child) { boneCache.get(ii).add(bone); boneCache.get(ii + 1).add(bone); continue outer; } if (child == parent) break; child = child.parent; } } current = current.parent; } while (current != null); nonIkBones.add(bone); } }
From source file:com.github.fauu.helix.core.Renderer.java
License:Open Source License
public void render(Camera camera, Array<RenderableProvider> renderableProviders, Array<Decal> decals) { final GL20 gl = Gdx.graphics.getGL20(); gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); gl.glClearColor(0.1f, 0.1f, 0.1f, 1); gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); gl.glEnable(GL20.GL_BLEND);/*from w w w .j a va 2 s . co m*/ gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); if (decalBatch == null) { defaultCameraGroupStrategy = new CameraGroupStrategy(camera); waterCameraGroupStrategy = new CameraGroupStrategy(waterCamera); decalBatch = new DecalBatch(defaultCameraGroupStrategy); } //waterCamera.moveTo(new Vector2(13, 19)); /* Render objects to framebuffer */ fb.begin(); gl.glClearColor(0, 0, 0, 0); gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); gl.glEnable(GL20.GL_BLEND); gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); renderContext.begin(); modelBatch.begin(waterCamera); for (int i = 1; i < renderableProviders.size - 1; i++) { modelBatch.render(renderableProviders.get(i)); } modelBatch.end(); renderContext.end(); decalBatch.setGroupStrategy(waterCameraGroupStrategy); if (decals != null) { decals.first().rotateX(50); decalBatch.add(decals.first()); decalBatch.flush(); decals.first().rotateX(-50); } // Vector3 waterPos = waterCamera.project(new Vector3(8, 0, 19)); // reflectionPixmap = ScreenUtils.getFrameBufferPixmap((int) waterPos.x, (int) waterPos.y, 348, 261); // reflectionPixmap = ScreenUtils.getFrameBufferPixmap(0, 0, 800, 600); fb.end(); // if (reflectionTexture == null) { // reflectionTexture = new Texture(reflectionPixmap); // } else { // reflectionTexture.draw(reflectionPixmap, 0, 0); // } ((WaterData) ((ModelInstance) renderableProviders .get(renderableProviders.size - 1)).userData).reflectionTexture = fb.getColorBufferTexture(); /* Render objects and terrain to the screen */ renderContext.begin(); modelBatch.begin(camera); modelBatch.render(renderableProviders); modelBatch.end(); renderContext.end(); decalBatch.setGroupStrategy(defaultCameraGroupStrategy); if (decals != null) { decalBatch.add(decals.first()); } decalBatch.flush(); spriteBatch.begin(); spriteBatch.enableBlending(); spriteBatch.draw(fb.getColorBufferTexture(), 0, 0, 800, 600); spriteBatch.end(); }
From source file:com.github.fauu.helix.editor.HelixEditor.java
License:Open Source License
@Override public void create() { instance = this; uiEventBus = new EventBus(); worldEventBus = new EventBus(); overworld = new Overworld(); setScreen(overworld);/*from w w w . j a v a2s .c o m*/ tagManager = overworld.getWorld().getManager(TagManager.class); areaManager = overworld.getWorld().getManager(AreaManager.class); tilePassageTargetPositionFieldState = new TilePassageTargetPositionFieldState(); tilePermissionListState = new TilePermissionListState(); tilePermissionListState.initialize(TilePermission.LEVEL0); toolbarState = new ToolbarState(); toolbarState.initialize(ToolType.TILE_PERMISSIONS); ui = new UI(); tilePassageAreaListState = new TilePassageAreaListState(); Array<String> areaNames = areaManager.getAllNames(); tilePassageAreaListState.initialize(areaNames, areaNames.first()); Gdx.input.setInputProcessor(new InputMultiplexer(ui.getStage(), new EditorInputEventProcessor())); loadAreaAction("area1"); }
From source file:com.kotcrab.vis.editor.module.scene.entitymanipulator.tool.PolygonTool.java
License:Apache License
private boolean checkCurrentVertexIntersection() { Array<Vector2> vertices = component.vertices; int index = vertices.indexOf(overVertex, true); if (index == -1) return true; Edge firstEdge;/*w ww .jav a2 s.c o m*/ Edge secondEdge; if (index == 0) firstEdge = new Edge(vertices.peek(), overVertex); else firstEdge = new Edge(vertices.get(index - 1), overVertex); if (index == vertices.size - 1) secondEdge = new Edge(vertices.first(), overVertex); else secondEdge = new Edge(vertices.get(index + 1), overVertex); Array<Edge> polygonEdges = new Array<>(); for (int i = 0; i < vertices.size - 1; i++) { polygonEdges.add(new Edge(vertices.get(i), vertices.get(i + 1))); } polygonEdges.add(new Edge(vertices.peek(), vertices.first())); for (Edge edge : polygonEdges) { if (edge.epsilonEquals(firstEdge, 0) || edge.epsilonEquals(secondEdge, 0)) continue; if (polygonLineIntersection(firstEdge.start, firstEdge.end, edge.start, edge.end)) return true; if (polygonLineIntersection(secondEdge.start, secondEdge.end, edge.start, edge.end)) return true; } return false; }
From source file:com.kotcrab.vis.editor.module.scene.ZIndexManipulator.java
License:Apache License
private void moveEntity(EditorObject entity, Array<EditorObject> overlappingEntities, boolean up) { if (overlappingEntities.size > 0) { int currentIndex = scene.entities.indexOf(entity, true); int targetIndex = scene.entities.indexOf(overlappingEntities.first(), true); for (EditorObject overlappingEntity : overlappingEntities) { int sceneIndex = scene.entities.indexOf(overlappingEntity, true); if (up ? sceneIndex < targetIndex : sceneIndex > targetIndex) targetIndex = sceneIndex; }/* w w w . jav a 2 s . c o m*/ actionGroup.execute(new ZIndexChangeAction(entity, currentIndex, targetIndex)); } }
From source file:com.kotcrab.vis.editor.ui.scene.SceneOutline.java
License:Apache License
private void buildTreeRecursively(Array<EntityProxy> groupProxies, int gid, Node parent) { GroupNode groupRoot = new GroupNode(groupProxies.first().getLayerID(), gid); if (parent == null) tree.add(groupRoot);//from w ww.ja va2s . com else parent.add(groupRoot); if (expandedNodes.contains(gid)) { groupRoot.setExpanded(true); } Array<EntityProxy> ignoreProxies = new Array<>(); for (EntityProxy proxy : groupProxies) { if (ignoreProxies.contains(proxy, true)) { continue; } int gidBefore = proxy.getGroupIdBefore(gid); if (gidBefore != -1) { Array<EntityProxy> result = entitiesCollector.collect(proxy.getLayerID(), gidBefore); ignoreProxies.addAll(result); buildTreeRecursively(result, gidBefore, groupRoot); continue; } groupRoot.add(new ProxyNode(proxy)); } }
From source file:com.kotcrab.vis.editor.util.EntityUtils.java
License:Apache License
public static String getEntitiesCommonFloatValue(Array<EditorObject> entities, FloatValue objValue) { float value = objValue.getFloat(entities.first()); for (EditorObject entity : entities) if (value != objValue.getFloat(entity)) return "?"; return NumberUtils.floatToString(value); }
From source file:com.kotcrab.vis.editor.util.EntityUtils.java
License:Apache License
public static void setCommonCheckBoxState(Array<EditorObject> entities, IndeterminateCheckbox target, BooleanValue value) {/*from w ww . java 2 s . com*/ boolean enabled = value.getBoolean(entities.first()); for (EditorObject entity : entities) { if (enabled != value.getBoolean(entity)) { target.setIndeterminate(true); return; } } target.setChecked(enabled); }
From source file:com.kotcrab.vis.editor.util.EntityUtils.java
License:Apache License
public static String getCommonString(Array<EditorObject> entities, String ifNotCommon, StringValue value) { String firstText = value.getString(entities.first()); for (EditorObject entity : entities) { if (value.getString(entity).equals(firstText) == false) return ifNotCommon; }/*ww w. j a va 2s .c om*/ return firstText; }