List of usage examples for com.badlogic.gdx.graphics.glutils ShapeRenderer ShapeRenderer
public ShapeRenderer()
From source file:com.mygdx.game.systems.ui.UiSystem.java
License:Apache License
public UiSystem(OrthographicCamera camera) { batch = new SpriteBatch(); shape = new ShapeRenderer(); shape.setAutoShapeType(true);//from www . j av a2 s .c om this.camera = camera; Gdx.input.setInputProcessor(this); String[] frameNames = { "butts01", "butts02", "butts03", "butts04", "butts05", "butts06" }; exampleAnim = new SpriteAnimation("butts.txt", frameNames); }
From source file:com.nebula2d.editor.framework.components.BoundingBox.java
License:Open Source License
@Override public void render(GameObject selectedObject, SpriteBatch batcher, Camera cam) { if (gameObject != null && w > 0 && h > 0) { batcher.end();//from w ww .j ava2 s.co m ShapeRenderer shape = new ShapeRenderer(); shape.setProjectionMatrix(cam.combined); shape.setColor(Color.RED); shape.begin(ShapeRenderer.ShapeType.Line); float halfw = w / 2.0f; float halfh = h / 2.0f; float x = gameObject.getPosition().x - halfw; float y = gameObject.getPosition().y - halfh; shape.rect(x, y, w, h); shape.end(); batcher.begin(); } }
From source file:com.nebula2d.editor.framework.components.Circle.java
License:Open Source License
@Override public void render(GameObject selectedObject, SpriteBatch batcher, Camera cam) { if (gameObject != null && r % 360 != 0) { batcher.end();// ww w . j a v a 2 s.c o m ShapeRenderer shape = new ShapeRenderer(); shape.setProjectionMatrix(cam.combined); shape.setColor(Color.RED); shape.begin(ShapeRenderer.ShapeType.Line); float x = gameObject.getPosition().x; float y = gameObject.getPosition().y; shape.circle(x, y, r); shape.end(); batcher.begin(); } }
From source file:com.nebula2d.editor.framework.GameObject.java
License:Open Source License
public void render(GameObject selectedObject, SpriteBatch batcher, Camera cam) { if (renderer != null && renderer.isEnabled()) { renderer.render(selectedObject, batcher, cam); } else {//from w w w .jav a 2s . co m batcher.end(); Gdx.gl.glEnable(GL20.GL_BLEND); ShapeRenderer shape = new ShapeRenderer(); shape.setProjectionMatrix(cam.combined); OrthographicCamera ortho = (OrthographicCamera) cam; shape.begin(ShapeRenderer.ShapeType.Filled); shape.setColor(new Color(0f, 1f, 0f, 0.5f)); shape.circle(getPosition().x, getPosition().y, 4 * ortho.zoom); shape.end(); Gdx.gl.glDisable(GL20.GL_BLEND); batcher.begin(); } for (IRenderable renderable : renderables) { if (((Component) renderable).isEnabled()) { renderable.render(selectedObject, batcher, cam); } } }
From source file:com.nebula2d.editor.ui.RenderAdapter.java
License:Open Source License
@Override public void render() { Gdx.graphics.getGL20().glClearColor(.17f, .17f, .17f, 1.0f); Gdx.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT); if (!enabled) return;//w w w . j a va 2 s . com if (camera == null) return; batcher.setProjectionMatrix(camera.projection); batcher.begin(); Project p = MainFrame.getProject(); if (p != null && p.getCurrentScene() != null) { p.getCurrentScene().render(selectedObject, batcher, camera); } batcher.end(); if (selectedObject != null && selectedObject.getRenderer() != null && selectedObject.getRenderer().isReady()) { Rectangle boundingBox = selectedObject.getRenderer().getBoundingBox(camera); if (boundingBox != null) { Gdx.gl.glEnable(GL20.GL_BLEND); // Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); ShapeRenderer shape = new ShapeRenderer(); shape.setColor(new Color(0.0f, 1.0f, 0.0f, 0.5f)); shape.begin(ShapeRenderer.ShapeType.Filled); float x = boundingBox.getX(); float y = boundingBox.getY(); shape.rect(x, y, boundingBox.getWidth(), boundingBox.getHeight()); shape.end(); Gdx.gl.glDisable(GL20.GL_BLEND); } } }
From source file:com.netthreads.gdx.app.core.ScreenGDX.java
License:Apache License
/** * Construct GDX screen./* www. j a va2 s .com*/ * * @param screenWidth * @param screenHeight */ public ScreenGDX(int screenWidth, int screenHeight) { this.screenWidth = screenWidth; this.screenHeight = screenHeight; shapeRenderer = new ShapeRenderer(); }
From source file:com.o2d.pkayjava.editor.plugins.ninepatch.EditingZone.java
License:Apache License
public EditingZone() { shapeRenderer = new ShapeRenderer(); addListener(new InputListener() { private Vector2 lastPoint; private int selectedSplit = -1; public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { selectedSplit = splitCollision(x, y); if (selectedSplit >= 0) { } else { lastPoint = new Vector2(x, y); }/*www . j ava 2s . c om*/ return true; } public void touchDragged(InputEvent event, float x, float y, int pointer) { if (selectedSplit >= 0) { if (selectedSplit == 0) { //left splits[0] = (int) ((x - shift.x - getWidth() / 2f) / currZoom + texture.getRegionWidth() / 2f); if (splits[0] > texture.getRegionWidth() - splits[1]) { int tmp = splits[1]; splits[1] = texture.getRegionWidth() - splits[0]; splits[0] = texture.getRegionWidth() - tmp; selectedSplit = 1; mouseOverSplit = selectedSplit; } splitUpdate(); return; } if (selectedSplit == 1) { splits[1] = -(int) ((x - shift.x - getWidth() / 2f) / currZoom - texture.getRegionWidth() / 2f); if (texture.getRegionWidth() - splits[1] < splits[0]) { int tmp = splits[0]; splits[0] = texture.getRegionWidth() - splits[1]; splits[1] = texture.getRegionWidth() - tmp; selectedSplit = 0; mouseOverSplit = selectedSplit; } splitUpdate(); return; } if (selectedSplit == 2) { // top splits[2] = -(int) ((y - shift.y - getHeight() / 2f) / currZoom - texture.getRegionHeight() / 2f); if (texture.getRegionHeight() - splits[2] < splits[3]) { int tmp = splits[2]; splits[2] = texture.getRegionHeight() - splits[3]; splits[3] = texture.getRegionHeight() - tmp; selectedSplit = 3; mouseOverSplit = selectedSplit; } splitUpdate(); return; } if (selectedSplit == 3) { splits[3] = (int) ((y - shift.y - getHeight() / 2f) / currZoom + texture.getRegionHeight() / 2f); if (splits[3] > texture.getRegionHeight() - splits[2]) { int tmp = splits[3]; splits[3] = texture.getRegionHeight() - splits[2]; splits[2] = texture.getRegionHeight() - tmp; selectedSplit = 2; mouseOverSplit = selectedSplit; } splitUpdate(); return; } } else { Vector2 diff = new Vector2(x - lastPoint.x, y - lastPoint.y); shiftBy(diff); lastPoint = new Vector2(x, y); } } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { selectedSplit = -1; if (listener != null) { listener.changed(splits.clone()); } } public boolean mouseMoved(InputEvent event, float x, float y) { mouseOverSplit = splitCollision(x, y); return false; } }); }
From source file:com.o2d.pkayjava.editor.view.ui.followers.PolygonFollower.java
License:Apache License
public void create() { polygonComponent = ComponentRetriever.get(entity, PolygonComponent.class); transformComponent = ComponentRetriever.get(entity, TransformComponent.class); shapeRenderer = new ShapeRenderer(); }
From source file:com.o2d.pkayjava.editor.view.ui.widget.actors.GridView.java
License:Apache License
public GridView() { gridSize = 50;/* w w w. j a v a 2 s .c om*/ gridLinesCount = 40; pixelsPerWU = Sandbox.getInstance().getPixelPerWU(); shapeRenderer = new ShapeRenderer(); for (int i = 0; i < gridLinesCount; i++) { Segment tmp = new Segment(i * gridSize - (gridLinesCount / 2 - 1) * gridSize, -(gridLinesCount / 2 - 1) * gridSize, i * gridSize - (gridLinesCount / 2 - 1) * gridSize, gridSize * gridLinesCount - (gridLinesCount / 2 - 1) * gridSize); lines.add(tmp); } for (int i = 0; i < gridLinesCount; i++) { Segment tmp = new Segment(-(gridLinesCount / 2 - 1) * gridSize, i * gridSize - (gridLinesCount / 2 - 1) * gridSize, gridSize * gridLinesCount - (gridLinesCount / 2 - 1) * gridSize, i * gridSize - (gridLinesCount / 2 - 1) * gridSize); lines.add(tmp); } this.setWidth(gridSize * gridLinesCount); this.setHeight(gridSize * gridLinesCount); zeroLabel = new VisLabel("0.0"); zeroLabel.setColor(new Color(1, 1, 1, 0.4f)); }
From source file:com.o2d.pkayjava.editor.view.ui.widget.actors.SpriterActor.java
License:Apache License
private void initSpriterAnimation() { FileHandle handle = irr.getSCMLFile(animationName); data = new SCMLReader(handle.read()).getData(); LibGdxLoader loader = new LibGdxLoader(data); loader.load(handle.file());/*from w ww . j a v a2s . co m*/ ShapeRenderer renderer = new ShapeRenderer(); drawer = new LibGdxDrawer(loader, renderer); currentAnimationIndex = 0; currentEntityIndex = 0; initPlayer(); }