List of usage examples for com.badlogic.gdx.graphics.g2d TextureRegion TextureRegion
public TextureRegion()
From source file:at.tugraz.ist.catroid.content.Costume.java
License:Open Source License
protected void checkImageChanged() { imageLock.acquireUninterruptibly();/* w ww. j a v a 2 s .com*/ if (imageChanged) { this.disposeTextures(); currentAlphaPixmap = null; if (costumeData == null) { xYWidthHeightLock.acquireUninterruptibly(); this.x += this.width / 2f; this.y += this.height / 2f; this.width = 0f; this.height = 0f; xYWidthHeightLock.release(); this.region = new TextureRegion(); imageChanged = false; imageLock.release(); return; } Pixmap pixmap; if (internalPath) { pixmap = new Pixmap(Gdx.files.internal(costumeData.getAbsolutePath())); } else { pixmap = new Pixmap(Gdx.files.absolute(costumeData.getAbsolutePath())); } xYWidthHeightLock.acquireUninterruptibly(); this.x += this.width / 2f; this.y += this.height / 2f; this.width = pixmap.getWidth(); this.height = pixmap.getHeight(); this.x -= this.width / 2f; this.y -= this.height / 2f; this.originX = this.width / 2f; this.originY = this.height / 2f; xYWidthHeightLock.release(); currentAlphaPixmap = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), Format.Alpha); currentAlphaPixmap.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight()); brightnessLock.acquireUninterruptibly(); if (brightnessValue != 1f) { pixmap = this.adjustBrightness(pixmap); } brightnessLock.release(); Texture texture = new Texture(pixmap); pixmap.dispose(); this.region = new TextureRegion(texture); imageChanged = false; } imageLock.release(); }
From source file:cmnworks.com.angrybee.Obstacles.java
License:Open Source License
public void draw(AngryBee parent) { TextureRegion targetRegion = new TextureRegion(); boolean hadIntersection = false; for (Obstacle island : this.islands) { if (!parent.Game.isOver()) { this.positionPolygon(island.position.x, island.position.y); }/*from w w w .ja v a 2 s .com*/ if (hadIntersection = this.isIntersectionOccur(parent, this.polygon, parent.Actor.polygon)) targetRegion = island.image; if (parent.Game.isOver()) { /* intersection effect */ if (!this.intersectionEffect) { if (hadIntersection) parent.Sound.intersection.play(); parent.Music.running.stop(); parent.Music.gameOver.play(); if (!parent.Actor.isScreenOut(parent) && hadIntersection) { island.image = new TextureRegion(targetRegion); island.image.setRegion(new Texture(this.setTextureIntersection)); if (targetRegion.isFlipY()) island.image.flip(false, true); } this.intersectionEffect = true; } ++this.getGameOverMSHold; } float x = parent.Game.isRunning() ? island.position.x -= 3 : island.position.x; parent.batch.draw(island.image, x, island.position.y); } }
From source file:com.bnotions.racing.actor.ButtonActor.java
License:Apache License
/** * Creates a new Button instance with the given name. * @param name the name//from ww w .jav a 2 s .c om */ public ButtonActor(String name) { super(); this.pressedRegion = new TextureRegion(); this.unpressedRegion = new TextureRegion(); addListener(); }
From source file:com.jupiter.europa.scene2d.TextureRegionActor.java
public TextureRegionActor() { this.region = new TextureRegion(); }
From source file:com.mygdx.java.MyGdxJava.java
License:Apache License
@Override public void create() { image = null;/* www .j av a 2s . com*/ Gdx.app.postRunnable(new Runnable() { @Override public void run() { try { start(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); /* * FileHandle fileHandle = Gdx.files.internal(Constants.CONFIG); * * try { PropertiesUtils.load(Constants.PROPERTIES, * fileHandle.reader()); } catch (IOException e) { e.printStackTrace(); * } * * Gdx.app.setLogLevel(Application.LOG_DEBUG); * * System.out.println(Constants.PROPERTIES.get("log.level")); */ batch = new SpriteBatch(); region = new TextureRegion(); region.setRegion(new Texture("badlogic.jpg")); batch = new SpriteBatch(); getData(); Gdx.input.setInputProcessor(new InputProcessor() { @Override public boolean touchUp(int screenX, int screenY, int pointer, int button) { // TODO Auto-generated method stub return false; } @Override public boolean touchDragged(int screenX, int screenY, int pointer) { // TODO Auto-generated method stub return false; } @Override public boolean touchDown(int screenX, int screenY, int pointer, int button) { getData(); return true; } @Override public boolean scrolled(int amount) { // TODO Auto-generated method stub return false; } @Override public boolean mouseMoved(int screenX, int screenY) { // TODO Auto-generated method stub return false; } @Override public boolean keyUp(int keycode) { // TODO Auto-generated method stub return false; } @Override public boolean keyTyped(char character) { // TODO Auto-generated method stub return false; } @Override public boolean keyDown(int keycode) { // TODO Auto-generated method stub return false; } }); // timer = new Timer(); // Task task = new Task() { // @Override // public void run() { // // getData(); // // } // }; // timer.scheduleTask(task, 0.01f, 0.01f); // timer.start(); }
From source file:es.eucm.ead.editor.view.builders.scene.draw.MeshHelper.java
License:Open Source License
/** * Initializes the {@link #frameBuffer}, {@link #showingTexRegion} and * {@link #flusher} to the coordinates the the {@link Stage}, only if they * are null. This method should only be called in {@link #layout()}. If the * {@link Stage} size changed, the resources are translated via * {@link #translateResources(Actor)}.//from www.j a v a2 s . c o m */ public void initializeRenderingResources() { createShader(); createMesh(); this.recalculateMatrix = true; if (this.showingTexRegion == null) { this.showingTexRegion = new TextureRegion(); } float w = scaledView.getWidth(), h = scaledView.getHeight(); if (fbo == null) { fbo = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false); } showingTexRegion.setRegion(fbo.getColorBufferTexture()); clampMinX = 0f; clampMinY = 0f; clampMaxX = w; clampMaxY = h; scaledView.localToStageCoordinates(temp.set(0f, 0f)); int stageX = MathUtils.round(temp.x), stageY = MathUtils.round(temp.y), width = MathUtils.round(w), height = MathUtils.round(h); showingTexRegion.setRegion(stageX, stageY, width, height); showingTexRegion.flip(false, true); if (this.flusher.pixmap == null) { this.flusher.pixmap = new Pixmap(width, height, Format.RGBA8888); flusher.x = stageX; flusher.y = stageY; } }
From source file:org.illarion.engine.backend.gdx.GdxGraphics.java
License:Open Source License
/** * Create a new instance of the graphics engine that is using libGDX to render. * * @param gdxGraphics the libGDX graphics instance that is used *//*from w w w .j ava 2s . c o m*/ GdxGraphics(@Nonnull final GdxEngine engine, @Nonnull final com.badlogic.gdx.Graphics gdxGraphics) { this.gdxGraphics = gdxGraphics; this.engine = engine; shapeRenderer = new ShapeRenderer(); spriteBatch = new SpriteBatch(1000, 10); tempColor1 = new com.badlogic.gdx.graphics.Color(); tempColor2 = new com.badlogic.gdx.graphics.Color(); tempColor3 = new com.badlogic.gdx.graphics.Color(); tempColor4 = new com.badlogic.gdx.graphics.Color(); tempRegion = new TextureRegion(); tempEngineRectangle = new Rectangle(); camera = new OrthographicCamera(); camera.zoom = 1.f; camera.setToOrtho(true); }