List of usage examples for com.badlogic.gdx.graphics.g2d TextureRegion TextureRegion
public TextureRegion(Texture texture, int width, int height)
From source file:CB_UI_Base.graphics.PolygonDrawable.java
License:Open Source License
@Override public boolean draw(Batch batch, float x, float y, float width, float height, float rotate) { synchronized (isDisposed) { if (isDisposed.get()) return true; if (po == null) { if (this.PAINT.getBitmapShader() == null) { if (texReg == null) createTexRegFromPixMap(); po = new PolygonRegion(texReg, VERTICES, TRIANGLES); } else { Texture inputTex = this.PAINT.getBitmapShader().getTexture(); if (inputTex != null) { inputTex.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); po = new PolygonRegion(new TextureRegion(inputTex, (int) this.WIDTH, (int) this.HEIGHT), VERTICES, TRIANGLES); }//from w w w . ja v a 2 s . c o m } } Color c = batch.getColor(); float a = c.a; float r = c.r; float g = c.g; float b = c.b; if (po == null) return true; if (this.PAINT.getBitmapShader() == null) { GL.setBatchColor(PAINT.getGlColor()); } else { batch.setColor(new Color(Color.WHITE)); } batch.flush(); try { ((PolygonSpriteBatch) batch).draw(po, x, y, width, height); } catch (Exception e) { e.printStackTrace(); } batch.flush(); // reset color batch.setColor(r, g, b, a); } return true; }
From source file:CB_UI_Base.graphics.PolygonDrawable.java
License:Open Source License
private void createTexRegFromPixMap() { if (isDisposed.get()) return;// w w w .j ava 2s . c o m int w = 2; int h = 2; pix = new Pixmap(w, h, Pixmap.Format.RGB565); pix.setColor(new Color(Color.WHITE)); pix.fillRectangle(0, 0, w, h); try { tex = new Texture(pix); } catch (Exception e) { tex = null; } if (tex != null) { tex.setFilter(TextureFilter.Linear, TextureFilter.MipMapLinearLinear); texReg = new TextureRegion(tex, (int) this.WIDTH, (int) this.HEIGHT); } pix.dispose(); pix = null; }
From source file:ch.coldpixel.alpha.npc.Enemy.java
public Enemy(float enemyX, float enemyY) { //PlayerSize//www . j a v a2 s . co m this.enemyWidth = 32; this.enemyHeight = 64; //Texture texture = new Texture("Graphics/NPC/Enemy.png"); enemyTexture = new TextureRegion(texture, 16, 16); //Position this.enemyX = enemyX; this.enemyY = enemyY; //Movement this.walkSpeed = 300; this.runSpeed = (int) (walkSpeed * 1.5); this.direction = 1; //Walk-timer WAIT_TIME = 1.8f; time = 0f; }
From source file:com.austinerb.project0.engine.SpriterLoader.java
License:Apache License
protected void createSprite(Reference ref, Pixmap image) { Texture tex = new Texture(image); tex.setFilter(TextureFilter.Linear, TextureFilter.Linear); TextureRegion texRegion = new TextureRegion(tex, (int) ref.dimensions.width, (int) ref.dimensions.height); files.put(ref, new Sprite(texRegion)); pixmapsToDispose.put(image, true);//from ww w .java2 s . co m }
From source file:com.binarytenshi.nopassing.state.MenuGameScreen.java
public MenuGameScreen() { stage = new Stage(); background = new Image(new Texture(FileHelper.getFile(Path.Menu, "back.png"))); Texture playTexture = new Texture(FileHelper.getFile(Path.Menu, "play.png")); Texture quitTexture = new Texture(FileHelper.getFile(Path.Menu, "quit.png")); ButtonStyle style = new ButtonStyle(); style.up = new TextureRegionDrawable(new TextureRegion(playTexture, 1024, 256)); Button playButton = new Button(style); playButton.setBounds(25, 50, 128, 32); playButton.addListener(new ClickListener() { @Override/*from w w w . jav a2s .com*/ public void clicked(InputEvent event, float x, float y) { NoPassing.instance.setScreen(GameScreen.Game.getScreen()); } }); style = new ButtonStyle(); style.up = new TextureRegionDrawable(new TextureRegion(quitTexture, 1024, 256)); Button quitButton = new Button(style); quitButton.setBounds(CameraHandler.getCamera().viewportWidth - 25 - 128, 50, 128, 32); quitButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { Gdx.app.exit(); } }); stage.addActor(background); stage.addActor(playButton); stage.addActor(quitButton); }
From source file:com.mygdx.game.utilities.ModelFactory.java
License:Apache License
public static Model buildBillboardModel(Texture texture, float width, float height) { TextureRegion textureRegion = new TextureRegion(texture, texture.getWidth(), texture.getHeight()); Material material = new Material(); material.set(new TextureAttribute(TextureAttribute.Diffuse, textureRegion)); material.set(new ColorAttribute(ColorAttribute.AmbientLight, Color.WHITE)); material.set(new BlendingAttribute()); return ModelFactory.buildPlaneModel(width, height, material, 0, 0, 1, 1); }
From source file:com.pogs.runpogsrun.util.SpriterLoader.java
License:Apache License
@Override public void load(final Reference ref, String path) { FileHandle f;/*from w w w . ja v a2 s . c o m*/ switch (Gdx.app.getType()) { case iOS: f = Gdx.files.absolute(path); break; default: f = Gdx.files.internal(path); break; } if (!f.exists()) throw new GdxRuntimeException("Could not find file handle " + path + "! Please check your paths."); if (this.packer == null && this.pack) this.packer = new PixmapPacker(this.atlasWidth, this.atlasHeight, Pixmap.Format.RGBA8888, 2, true); final Pixmap pix; Texture tex; TextureRegion texRegion; if (!Gdx.graphics.isGL20Available()) { Pixmap temp = new Pixmap(f); pix = new Pixmap(MathUtils.nextPowerOfTwo(temp.getWidth()), MathUtils.nextPowerOfTwo(temp.getHeight()), temp.getFormat()); pix.drawPixmap(temp, 0, 0); tex = new Texture(pix); texRegion = new TextureRegion(tex, temp.getWidth(), temp.getHeight()); temp.dispose(); } else { pix = new Pixmap(f); tex = new Texture(pix); texRegion = new TextureRegion(tex, pix.getWidth(), pix.getHeight()); } tex.setFilter(TextureFilter.Linear, TextureFilter.Linear); if (this.packer != null) packer.pack(ref.fileName, pix); this.files.put(ref, new Sprite(texRegion)); pix.dispose(); }
From source file:com.qualixium.fishcave.actors.FishActor.java
public FishActor() { WIDTH = 128;/* ww w . ja v a 2 s. c o m*/ HEIGHT = 44; fish = new TextureRegion(Assets.fish, WIDTH, HEIGHT); TextureRegion[][] animation = fish.split(WIDTH / 2, HEIGHT); fishFrames = new TextureRegion[animation.length * animation[0].length]; int index = 0; for (TextureRegion[] animation1 : animation) { for (TextureRegion animation11 : animation1) { fishFrames[index++] = animation11; } } fishAnimation = new Animation(0.2f, fishFrames); setSize(WIDTH / 2, HEIGHT); setPosition(START_X, START_Y); }
From source file:com.qualixium.fishcave.actors.ObstaclesActor.java
public ObstaclesActor() { rock = new TextureRegion(Assets.rock, Assets.rock.getWidth(), Math.round(GameScreen.stage.getHeight() / 2)); rockDown = new TextureRegion(rock); rockDown.flip(false, true);//from w w w. j ava2 s .c o m ground = new TextureRegion(Assets.ground); ceiling = new TextureRegion(ground); ceiling.flip(true, true); }
From source file:com.tnf.ptm.sound.SoundTestCmp.java
License:Apache License
SoundTestCmp() {
mySpriteBatch = new SpriteBatch();
myTsDiv = new ArrayList<TextureRegion>();
myTsComb = new ArrayList<TextureRegion>();
myWt = new Texture("imgSrcs/misc/whiteTex.png");
Texture full = new Texture("testImgs/testCombined.png");
for (int i = 0; i < 16; i++) {
Texture div = new Texture("testImgs/test_" + i + ".png");
TextureRegion divReg = new TextureRegion(div, 64, 64);
myTsDiv.add(divReg);/*w w w .j a va 2s . c om*/
TextureRegion regComb = new TextureRegion(full, i * 64, 0, 64, 64);
myTsComb.add(regComb);
}
}