List of usage examples for com.badlogic.gdx.utils Array iterator
public Iterator<T> iterator()
From source file:be.ac.ucl.lfsab1509.bouboule.game.level.LevelLoader.java
License:Open Source License
/** * Load all the Bouboule contained in the 'file' level. * //from w w w.j ava 2 s. c o m * public void readLevelBouboule(GraphicManager graphicManager) */ public void readLevelBouboule(final GraphicManager graphicManager) { Array<Element> maps = file.getChildrenByName("Bouboule"); //iterate on all the children for (Iterator<Element> map = maps.iterator(); map.hasNext();) { Element boub = map.next(); float radius = Float.parseFloat(boub.getAttribute("radius")); BodyType bodyType = BodyType.DynamicBody; float density = Float.parseFloat(boub.getAttribute("density")); float elasticity = Float.parseFloat(boub.getAttribute("elasticity")); float px = Float.parseFloat(boub.getAttribute("px")) * GlobalSettings.HD; float py = Float.parseFloat(boub.getAttribute("py")) * GlobalSettings.HD; float angle = Float.parseFloat(boub.getAttribute("angle")); int AILevel = Integer.parseInt(boub.getAttribute("AILevel")); short entity = Short.parseShort(boub.getAttribute("entity")); boolean inverted = Boolean.parseBoolean(boub.getAttribute("inverted", "False")); String texRegionPath; String type = boub.getAttribute("type"); String directory = (type.equals("normal")) ? BoubImages.BOUB_DIR_NORMAL : (type.equals("small")) ? BoubImages.BOUB_DIR_SMALL : BoubImages.BOUB_DIR_GIANT; String jsonFile = directory + BoubImages.BOUB_JSON_EXT; if (entity == Entity.PLAYER) texRegionPath = directory + GlobalSettings.PROFILE.getBoubName() + BoubImages.BOUB_EXTENTION; else texRegionPath = directory + boub.getAttribute("texRegionPath"); Bouboule body = new Bouboule(radius, bodyType, density, elasticity, px, py, angle, texRegionPath, jsonFile, "boub_" + type, entity, AILevel); graphicManager.addBody(body); if (inverted) { ((Sprite) body.getBody().getFixtureList().get(0).getUserData()).rotate90(true); ((Sprite) body.getBody().getFixtureList().get(0).getUserData()).rotate90(true); AI.setInvertedOrientation(); } else // revert axe if it's inverted AI.setNormalOrientation(); } }
From source file:be.ac.ucl.lfsab1509.bouboule.game.level.LevelLoader.java
License:Open Source License
/** * Load the nodes for the AI.//w ww . ja v a2s . c om * * public void readLevelMapNodes() */ public void readLevelMapNodes() { Element mapNodes = file.getChildByName("MapNodes"); Array<Element> node = mapNodes.getChildrenByName("NodeAllow"); MapNode mapNode; Element newNode; GlobalSettings.ARENAWAYPOINTALLOW.clear(); //iterate on all the children for (Iterator<Element> nodes = node.iterator(); nodes.hasNext();) { newNode = nodes.next(); float px = Float.parseFloat(newNode.getAttribute("px")) * GlobalSettings.HD; float py = Float.parseFloat(newNode.getAttribute("py")) * GlobalSettings.HD; float weight = Float.parseFloat(newNode.getAttribute("weight")) * GlobalSettings.HD; mapNode = new MapNode(px, py, weight); GlobalSettings.ARENAWAYPOINTALLOW.add(mapNode); Gdx.app.log("XML NODES", mapNode.toString()); } }
From source file:be.ac.ucl.lfsab1509.bouboule.game.level.LevelLoader.java
License:Open Source License
/** * Load the obstacles of the 'file' level. * //ww w . j ava 2s .com * public void readLevelObstacles(GraphicManager graphicManager) */ public void readLevelObstacles(final GraphicManager graphicManager) { Element obstaclesGroup = file.getChildByName("Obstacles"); if (obstaclesGroup == null) { return; } Array<Element> obstaclesArray = obstaclesGroup.getChildrenByName("Obstacle"); Element newobstacle; for (Iterator<Element> obstacleElem = obstaclesArray.iterator(); obstacleElem.hasNext();) { newobstacle = obstacleElem.next(); BodyType bodyType = (newobstacle.getAttribute("bodyType").equals("Dynamic")) ? BodyType.DynamicBody : BodyType.StaticBody; float density = Float.parseFloat(newobstacle.getAttribute("density")); float elasticity = Float.parseFloat(newobstacle.getAttribute("elasticity")); float px = Float.parseFloat(newobstacle.getAttribute("px")); // * HD only for movable obstacles float py = Float.parseFloat(newobstacle.getAttribute("py")); float angle = Float.parseFloat(newobstacle.getAttribute("angle")); float initAccX = Float.parseFloat(newobstacle.getAttribute("accx", "0")) * GlobalSettings.HD * GlobalSettings.HD * GlobalSettings.HD; float initAccY = Float.parseFloat(newobstacle.getAttribute("accy", "0")) * GlobalSettings.HD * GlobalSettings.HD * GlobalSettings.HD; float time = Float.parseFloat(newobstacle.getAttribute("time", "0")); String file = newobstacle.getAttribute("file"); String texRegionPath = file + ".png"; String jsonFile = file + ".json"; String jsonName = extractFileName(file); boolean produce = Boolean.parseBoolean(newobstacle.getAttribute("produce", "false")); boolean blink = Boolean.parseBoolean(newobstacle.getAttribute("blink", "false")); if (produce) { addContinuousObstacle(graphicManager, time, bodyType, density, elasticity, px * GlobalSettings.HD, py * GlobalSettings.HD, angle, texRegionPath, jsonFile, jsonName, initAccX, initAccY); } else { Obstacle obs = new Obstacle(bodyType, density, elasticity, px, py, angle, texRegionPath, jsonFile, jsonName, initAccX, initAccY); graphicManager.addBody(obs); if (blink) { setBlink(obs, time); } } Gdx.app.log("XML", "Obstacle loaded : " + produce + jsonName + bodyType.toString() + time); } }
From source file:com.anythingmachine.tiledMaps.TiledMapHelper.java
License:Apache License
public void destroyMap() { Array<Body> bodies = new Array<Body>(); GamePlayManager.world.getBodies(bodies); Iterator it = bodies.iterator(); while (it.hasNext()) { Body b = (Body) it.next();/*from w ww . j av a2 s .c o m*/ Object dat = b.getUserData(); if (dat != null && dat instanceof Entity) { Entity e = (Entity) dat; if (e.type == EntityType.PLATFORM || e.type == EntityType.WALL || e.type == EntityType.LEVELWALL || e.type == EntityType.STAIRS || e.type == EntityType.AINODE || e.type == EntityType.DOOR) { // System.out.println(e.type); GamePlayManager.world.destroyBody(b); } } it.remove(); } }
From source file:com.github.fauu.helix.system.RenderingSystem.java
License:Open Source License
@Override protected void removed(Entity e) { Displayable displayableToRemove = displayableMapper.get(e).get(); for (Array<? extends Displayable> displayableCollection : displayableCollections) { Iterator<? extends Displayable> it = displayableCollection.iterator(); while (it.hasNext()) { if (it.next().equals(displayableToRemove)) { it.remove();/* w w w. ja v a 2 s . c o m*/ } } } }
From source file:com.github.unluckyninja.mousekiller.MainMenu.java
License:Open Source License
private void logics(float delta) { if (TimeUtils.millis() - lastshottime >= 200) { lastshottime = TimeUtils.millis(); Body body = mk.world.createBody(bodyDef); body.setLinearVelocity(5 * MathUtils.cos(i), 5 * MathUtils.sin(i++)); body.createFixture(box, 1);//from ww w.ja v a 2s. com } Array<Body> list = new Array<>(); // mk.world.getBodies(list); HashSet<Body> set = new HashSet<>(); for (Iterator<Body> it = list.iterator(); it.hasNext();) { Body body = it.next(); Vector2 vec = body.getWorldCenter(); boolean remove = false; float xdiffer = vec.x - 20; if (xdiffer >= 3 || xdiffer < -3) { remove = true; } float ydiffer = vec.y - 20; if (!remove && (ydiffer >= 3 || ydiffer < -3)) { remove = true; } if (remove) { set.add(body); } } for (Body body : set) { mk.world.destroyBody(body); } // camera.position.set(mk.killer.getCoords().x, mk.killer.getCoords().y, 0); // camera.update(); }
From source file:com.kotcrab.vis.editor.module.physicseditor.PRigidBodiesScreen.java
License:Apache License
private void clearWorld() { ballsBodies.clear();//from w w w. j a v a2 s.c om ballsSprites.clear(); Array<Body> bodiesList = new Array<>(); world.getBodies(bodiesList); Iterator<Body> bodies = bodiesList.iterator(); while (bodies.hasNext()) world.destroyBody(bodies.next()); }
From source file:com.kotcrab.vis.editor.module.project.FileAccessModule.java
License:Apache License
public Array<FileHandle> getSceneFiles() { Array<FileHandle> files = FileUtils.listRecursive(getAssetsFolder()); Iterator<FileHandle> it = files.iterator(); while (it.hasNext()) if (it.next().extension().equals("scene") == false) it.remove();/*w ww.ja v a 2 s . co m*/ files.sort((o1, o2) -> o1.path().toLowerCase().compareTo(o2.path().toLowerCase())); return files; }
From source file:com.ray3k.skincomposer.dialog.DialogDrawables.java
License:Open Source License
public DialogDrawables(Skin skin, String windowStyleName, StyleProperty property, DialogFactory dialogFactory, JsonData jsonData, ProjectData projectData, AtlasData atlasData, Main main, EventListener listener) { super("", skin, windowStyleName); this.dialogFactory = dialogFactory; this.jsonData = jsonData; this.projectData = projectData; this.atlasData = atlasData; this.main = main; instance = this; this.listener = listener; filesDroppedListener = (Array<FileHandle> files) -> { Iterator<FileHandle> iter = files.iterator(); while (iter.hasNext()) { FileHandle file = iter.next(); if (file.isDirectory() || !(file.name().toLowerCase().endsWith(".png") || file.name().toLowerCase().endsWith(".jpg") || file.name().toLowerCase().endsWith(".jpeg") || file.name().toLowerCase().endsWith(".bmp") || file.name().toLowerCase().endsWith(".gif"))) { iter.remove();// w w w .j a va 2 s.c om } } if (files.size > 0) { drawablesSelected(files); } }; main.getDesktopWorker().addFilesDroppedListener(filesDroppedListener); this.property = property; drawablePairs = new ObjectMap<>(); gatherDrawables(); produceAtlas(); populate(); }
From source file:com.ray3k.skincomposer.dialog.DialogFonts.java
License:Open Source License
public DialogFonts(final Skin skin, String styleName, StyleProperty styleProperty, JsonData jsonData, ProjectData projectData, AtlasData atlasData, Main main, EventListener listener) { super("", skin, styleName); this.jsonData = jsonData; this.projectData = projectData; this.atlasData = atlasData; this.main = main; this.listener = listener; this.skin = skin; this.styleProperty = styleProperty; fonts = jsonData.getFonts();/*from w ww . j a v a2 s .c o m*/ drawables = atlasData.getDrawables(); fontMap = new ObjectMap<>(); produceAtlas(); filesDroppedListener = (Array<FileHandle> files) -> { Iterator<FileHandle> iter = files.iterator(); while (iter.hasNext()) { FileHandle file = iter.next(); if (file.isDirectory() || !file.name().toLowerCase().endsWith(".fnt")) { iter.remove(); } } if (files.size > 0) { fontNameDialog(files, 0); } }; main.getDesktopWorker().addFilesDroppedListener(filesDroppedListener); setFillParent(true); if (styleProperty != null) { getContentTable().add(new Label("Select a Font...", skin, "title")); getContentTable().row(); } else { getContentTable().add(new Label("Fonts", skin, "title")); getContentTable().row(); } Table table = new Table(); table.defaults().pad(2.0f); table.add(new Label("Sort by: ", skin)).padLeft(20.0f); selectBox = new SelectBox<>(skin); selectBox.setItems(new String[] { "A-Z", "Z-A", "Oldest", "Newest" }); selectBox.addListener(new ChangeListener() { @Override public void changed(ChangeListener.ChangeEvent event, Actor actor) { sortBySelectedMode(); } }); selectBox.addListener(main.getHandListener()); table.add(selectBox); TextButton imageButton = new TextButton("New Font", skin, "new"); imageButton.addListener(new ChangeListener() { @Override public void changed(ChangeListener.ChangeEvent event, Actor actor) { Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Arrow); newFontDialog(); } }); imageButton.addListener(main.getHandListener()); table.add(imageButton).expandX(); getContentTable().add(table).expandX().left(); getContentTable().row(); key(Keys.ESCAPE, false); if (styleProperty != null) { button("Clear Font", true); button("Cancel", false); getButtonTable().getCells().first().getActor().addListener(main.getHandListener()); getButtonTable().getCells().get(1).getActor().addListener(main.getHandListener()); } else { button("Close", false); getButtonTable().getCells().first().getActor().addListener(main.getHandListener()); } getButtonTable().padBottom(15.0f); fontsTable = new Table(); table = new Table(); table.add(fontsTable).pad(5.0f); scrollPane = new ScrollPane(table, skin); scrollPane.setFadeScrollBars(false); getContentTable().add(scrollPane).grow(); }