List of usage examples for com.badlogic.gdx.graphics.g2d SpriteBatch draw
@Override
public void draw(Texture texture, float x, float y, float originX, float originY, float width, float height,
float scaleX, float scaleY, float rotation, int srcX, int srcY, int srcWidth, int srcHeight,
boolean flipX, boolean flipY)
From source file:com.dinhanh.myUtils.ScreenTransitionFade.java
License:Apache License
@Override public void render(SpriteBatch batch, Texture currScreen, Texture nextScreen, float alpha) { float w = currScreen.getWidth(); float h = currScreen.getHeight(); alpha = Interpolation.fade.apply(alpha); Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); batch.begin();/* www . j av a2s .com*/ batch.setColor(1, 1, 1, 1); batch.draw(currScreen, 0, 0, 0, 0, w, h, 1, 1, 0, 0, 0, currScreen.getWidth(), currScreen.getHeight(), false, true); batch.setColor(1, 1, 1, alpha); batch.draw(nextScreen, 0, 0, 0, 0, w, h, 1, 1, 0, 0, 0, nextScreen.getWidth(), nextScreen.getHeight(), false, true); batch.end(); }
From source file:com.dinhanh.myUtils.ScreenTransitionSlice.java
License:Apache License
@Override public void render(SpriteBatch batch, Texture currScreen, Texture nextScreen, float alpha) { float w = currScreen.getWidth(); float h = currScreen.getHeight(); float x = 0;/*from w ww.jav a 2 s. c o m*/ float y = 0; int sliceWidth = (int) (w / sliceIndex.size); Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); batch.draw(currScreen, 0, 0, 0, 0, w, h, 1, 1, 0, 0, 0, currScreen.getWidth(), currScreen.getHeight(), false, true); if (easing != null) alpha = easing.apply(alpha); for (int i = 0; i < sliceIndex.size; i++) { // current slice/column x = i * sliceWidth; // vertical displacement using randomized list of slice indices float offsetY = h * (1 + sliceIndex.get(i) / (float) sliceIndex.size); switch (direction) { case UP: y = -offsetY + offsetY * alpha; break; case DOWN: y = offsetY - offsetY * alpha; break; case UP_DOWN: if (i % 2 == 0) { y = -offsetY + offsetY * alpha; } else { y = offsetY - offsetY * alpha; } break; } batch.draw(nextScreen, x, y, 0, 0, sliceWidth, h, 1, 1, 0, i * sliceWidth, 0, sliceWidth, nextScreen.getHeight(), false, true); } batch.end(); }
From source file:com.dinhanh.myUtils.ScreenTransitionSlide.java
License:Apache License
@Override public void render(SpriteBatch batch, Texture currScreen, Texture nextScreen, float alpha) { float w = currScreen.getWidth(); float h = currScreen.getHeight(); float x = 0;// w ww . j av a2 s .co m float y = 0; if (easing != null) alpha = easing.apply(alpha); // calculate position offset switch (direction) { case LEFT: x = -w * alpha; if (!slideOut) x += w; break; case RIGHT: x = w * alpha; if (!slideOut) x -= w; break; case UP: y = h * alpha; if (!slideOut) y -= h; break; case DOWN: y = -h * alpha; if (!slideOut) y += h; break; } // drawing order depends on slide type ('in' or 'out') Texture texBottom = slideOut ? nextScreen : currScreen; Texture texTop = slideOut ? currScreen : nextScreen; // finally, draw both screens Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); batch.draw(texBottom, 0, 0, 0, 0, w, h, 1, 1, 0, 0, 0, currScreen.getWidth(), currScreen.getHeight(), false, true); batch.draw(texTop, x, y, 0, 0, w, h, 1, 1, 0, 0, 0, nextScreen.getWidth(), nextScreen.getHeight(), false, true); batch.end(); }
From source file:com.ethereal.rm.game.objects.Brick.java
@Override public void render(SpriteBatch batch) { TextureRegion reg = null;//from www . j a va2 s. c om reg = redBrick; //batch.draw(reg.getTexture(), position.x + relX, position.y + //relY, origin.x, origin.y, dimension.x, dimension.y, //scale.x, scale.y, rotation+90, reg.getRegionX(), reg.getRegionY(), //reg.getRegionWidth(), reg.getRegionHeight(), false, false); batch.draw(reg.getTexture(), // Texture position.x + relX, position.y + relY, // x, y origin.x, origin.y, // originX, originY dimension.x, dimension.y, // width, height //Constants.WORLD_TO_SCREEN,Constants.WORLD_TO_SCREEN, // scaleX, scaleY scale.x, scale.y, 90.0f, // rot (degrees) reg.getRegionX(), reg.getRegionY(), // srcX, srcY reg.getRegionWidth(), reg.getRegionHeight(), // srcWidth, srcHeight false, false); // flipX, flipY }
From source file:com.me.myverilogTown.TrafficControl.java
License:Open Source License
public void render_signal(TrafficSignalState signal, GridNode grid, float rot, SpriteBatch batch, Texture stop, Texture go, Texture left, Texture right, Texture forward) { // TODO: define grid size = 64 px int x = (grid.getX() - 1) * 64; int y = (grid.getY() - 1) * 64; Texture texture = null;//from w w w . j av a 2 s .co m switch (signal) { case GO: texture = go; break; case GO_FORWARD: texture = forward; break; case GO_LEFT: texture = left; break; case GO_RIGHT: texture = right; break; case STOP: texture = stop; break; default: texture = stop; } batch.draw(texture, x, y, 32, 32, 64, 64, 0.7f, 0.7f, rot, 0, 0, 64, 64, false, false); }
From source file:com.me.myverilogTown.TrafficControl.java
License:Open Source License
public void render_highlighted_stop(SpriteBatch batch, Texture stop_highlighted) { if (goNorth != null) { batch.draw(stop_highlighted, (goNorth.getX() - 1) * 64, (goNorth.getY() - 1) * 64, 32, 32, 64, 64, 0.7f, 0.7f, 0f, 0, 0, 64, 64, false, false); }//from www. j a v a 2s . c o m if (goSouth != null) { batch.draw(stop_highlighted, (goSouth.getX() - 1) * 64, (goSouth.getY() - 1) * 64, 32, 32, 64, 64, 0.7f, 0.7f, 0f, 0, 0, 64, 64, false, false); } if (goEast != null) { batch.draw(stop_highlighted, (goEast.getX() - 1) * 64, (goEast.getY() - 1) * 64, 32, 32, 64, 64, 0.7f, 0.7f, 0f, 0, 0, 64, 64, false, false); } if (goWest != null) { batch.draw(stop_highlighted, (goWest.getX() - 1) * 64, (goWest.getY() - 1) * 64, 32, 32, 64, 64, 0.7f, 0.7f, 0f, 0, 0, 64, 64, false, false); } }
From source file:com.me.myverilogTown.TrafficControl.java
License:Open Source License
public void render_complied_failed_stop(SpriteBatch batch, Texture stop_complied_failed) { if (goNorth != null) { batch.draw(stop_complied_failed, (goNorth.getX() - 1) * 64, (goNorth.getY() - 1) * 64, 32, 32, 64, 64, 0.7f, 0.7f, 0f, 0, 0, 64, 64, false, false); }//w w w .ja v a 2s . co m if (goSouth != null) { batch.draw(stop_complied_failed, (goSouth.getX() - 1) * 64, (goSouth.getY() - 1) * 64, 32, 32, 64, 64, 0.7f, 0.7f, 0f, 0, 0, 64, 64, false, false); } if (goEast != null) { batch.draw(stop_complied_failed, (goEast.getX() - 1) * 64, (goEast.getY() - 1) * 64, 32, 32, 64, 64, 0.7f, 0.7f, 0f, 0, 0, 64, 64, false, false); } if (goWest != null) { batch.draw(stop_complied_failed, (goWest.getX() - 1) * 64, (goWest.getY() - 1) * 64, 32, 32, 64, 64, 0.7f, 0.7f, 0f, 0, 0, 64, 64, false, false); } }
From source file:com.mrandmrsjian.freakingsum.screens.transitions.ScreenTransitionFade.java
License:Apache License
@Override public void render(SpriteBatch batch, Texture currScreen, Texture nextScreen, float alpha) { float w = currScreen.getWidth(); float h = currScreen.getHeight(); alpha = Interpolation.fade.apply(alpha); Gdx.gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin();/*from www . ja v a 2 s. c o m*/ batch.setColor(1, 1, 1, 1); batch.draw(currScreen, 0, 0, 0, 0, w, h, 1, 1, 0, 0, 0, currScreen.getWidth(), currScreen.getHeight(), false, true); batch.setColor(1, 1, 1, alpha); batch.draw(nextScreen, 0, 0, 0, 0, w, h, 1, 1, 0, 0, 0, nextScreen.getWidth(), nextScreen.getHeight(), false, true); batch.end(); }
From source file:com.neidert.swinkey.Drawable.java
public void draw(SpriteBatch batch) { batch.draw(texture, xAugmented * screen.widthratio - Game.camera, yAugmented * screen.heightratio, XrotationAnchor, YrotationAnchor, width, height, 1, 1, rotation, 0, 0, texture.getWidth(), texture.getHeight(), flipX, flipY); }
From source file:com.neidert.swinkey.GameOver.java
@Override public void draw(SpriteBatch batch) { update();//from w w w. j a v a 2 s.c o m batch.draw(texture, xAugmented * screen.widthratio, yAugmented * screen.heightratio, XrotationAnchor, YrotationAnchor, width, height, 1, 1, rotation, 0, 0, texture.getWidth(), texture.getHeight(), flipX, flipY); }