本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.TextureRegion.flip方法的典型用法代码示例。如果您正苦于以下问题:Java TextureRegion.flip方法的具体用法?Java TextureRegion.flip怎么用?Java TextureRegion.flip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.g2d.TextureRegion
的用法示例。
在下文中一共展示了TextureRegion.flip方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
/**
* Sets the current position of the rendered {@link Decal}, and the rotation given by the bullet direction.
*
* @param entityId the bullet id
* @param renderSystem the delegating {@link RenderSystem}
*/
@Override
public void process(int entityId, RenderSystem renderSystem) {
PhysicComponent physic = renderSystem.getMapperPhysic().get(entityId);
RenderComponent render = renderSystem.getMapperRender().get(entityId);
float deg = (float) (Math.atan2(physic.body.getLinearVelocity().y, physic.body.getLinearVelocity().x) * 180.0 / Math.PI);
Decal decal = renderSystem.getDecalMap().get(entityId);
decal.setRotationZ(deg);
float stateTime = renderSystem.getStateTime();
TextureRegion region = render.getCurrentKeyFrame(stateTime);
region.flip(region.isFlipX() ^ render.flipX, region.isFlipY() ^ render.flipY);
decal.setTextureRegion(region);
RenderComponent.RenderTemplate.AnimationTemplate template = render.getCurrentAnimation();
decal.setWidth(template.width);
decal.setHeight(template.height);
decal.setPosition(physic.body.getPosition().x, physic.body.getPosition().y, decal.getZ());
}
示例2: PixelBuffer
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
public PixelBuffer() {
super(Pixmap.Format.RGBA8888, Scene.BUFFER_WIDTH, Scene.BUFFER_HEIGHT, false);
getColorBufferTexture().setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
pixelBufferRegion = new TextureRegion(getColorBufferTexture(), 0, 0, Scene.BUFFER_WIDTH, Scene.BUFFER_HEIGHT);
pixelBufferRegion.flip(false, true);
}
示例3: loadTextureRegion
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
@Override
public TextureRegion loadTextureRegion(String textureFile)
{
Texture texture = loadTexture(textureFile, Format.RGBA4444, true);
TextureRegion tr = new TextureRegion(texture);
//flip for system of y-axis down
if(Game.isYdown())
tr.flip(false, true);
return tr;
}
示例4: setupEye
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
private void setupEye(Eye eye, int width, int height, boolean hasStencil) {
FrameBuffer buffer = new FrameBuffer(Format.RGBA8888, width, height, true, hasStencil);
TextureRegion region = new TextureRegion(buffer.getColorBufferTexture());
region.flip(false, true);
VRCamera camera = new VRCamera(this, eye);
camera.near = 0.1f;
camera.far = 1000f;
perEyeData[eye.index] = new VRPerEyeData(buffer, region, camera);
}
示例5: load
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
public static void load() {
texture = new Texture(Gdx.files.internal("data/boytexture.png"));
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
bg = new TextureRegion(new Texture((Gdx.files.internal("data/floor.png"))));
bg.flip(false, true);
boyhead = new TextureRegion(new Texture((Gdx.files.internal("data/boy.png"))));
boyhead.flip(false, true);
boyshadow = new TextureRegion(new Texture((Gdx.files.internal("data/boyshadow.png"))));
boyshadow.flip(false, true);
goal = new TextureRegion(new Texture((Gdx.files.internal("data/kth.png"))));
goal.flip(false, true);
wall = new TextureRegion(new Texture((Gdx.files.internal("data/wall2.png"))));
wall.flip(false, true);
wall2 = new TextureRegion(new Texture((Gdx.files.internal("data/wall.png"))));
wall2.flip(false, true);
dead = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav"));
coin = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav"));
flap = Gdx.audio.newSound(Gdx.files.internal("data/flap.wav"));
wallfx = Gdx.audio.newSound(Gdx.files.internal("data/vulture.wav"));
goalfx = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav"));
font = new BitmapFont(Gdx.files.internal("data/text.fnt"));
font.setScale(.25f, -.25f);
shadow = new BitmapFont(Gdx.files.internal("data/shadow.fnt"));
shadow.setScale(.25f, -.25f);
fontSmall = new BitmapFont(Gdx.files.internal("data/text.fnt"));
fontSmall.setScale(.10f, -.10f);
prefs = Gdx.app.getPreferences("Maze");
}
示例6: create
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
@Override
public void create() {
Array<String> names = getCore().getImagePacks().get(DATA_PATH + "/obstacles");
obstacleTexture = getCore().getAtlas().findRegion(names.random());
obstacleFlipped = new TextureRegion(obstacleTexture);
obstacleFlipped.flip(false, true);
timer = (obstacleTexture.getRegionWidth() + GameState.OBSTACLE_GAP) / GameState.SCROLL_SPEED;
}
示例7: load
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
public static void load() {
texture = new Texture(Gdx.files.internal("data/texture.png"));
texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
bg = new TextureRegion(texture, 0, 0, 136, 43);
bg.flip(false, true);
grass = new TextureRegion(texture, 0, 43, 143, 11);
grass.flip(false, true);
birdDown = new TextureRegion(texture, 136, 0, 17, 12);
birdDown.flip(false, true);
bird= new TextureRegion(texture,153,0,17,12);
bird.flip(false,true);
birdUp=new TextureRegion(texture,170,0,17,12);
birdUp.flip(false,true);
TextureRegion[] birds = {birdDown, bird, birdUp};
birdAnimation=new Animation(0.06f,birds);
birdAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);
skullUp =new TextureRegion(texture,192,0,24,14);
skullDown = new TextureRegion(skullUp);
skullDown.flip(false,true);
bar = new TextureRegion(texture, 136, 16, 22, 3);
bar.flip(false,true);
}
示例8: initialize
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
private void initialize() {
//LibGDX setup
camera = new OrthographicCamera();
viewPort = new FitViewport(256, 240, camera);
viewPort.apply();
camera.position.set(camera.viewportWidth / 2, camera.viewportHeight / 2, 0);
shapeRenderer = new ShapeRenderer();
shapeRenderer.setAutoShapeType(true);
//Initialize shaders
vertexShader = Gdx.files.internal("shaders/vertex_shader.glsl").readString();
fragmentShader = Gdx.files.internal("shaders/fragment_shader.glsl").readString();
shaderProgram = new ShaderProgram(vertexShader, fragmentShader);
//Initialize attribute value (used by fragmentShader)
initializeAttributes();
//Make the mouse cursor transparent
Pixmap pixmap = new Pixmap(16, 16, Pixmap.Format.RGBA8888);
pixmap.setColor(Color.argb8888(0, 0, 0, 0));
pixmap.fill();
Gdx.graphics.setCursor(Gdx.graphics.newCursor(pixmap, 0, 0));
pixmap.dispose();
//Initialize transparent mask sprite
transparentMaskPixmap = new Pixmap(8, 8, Pixmap.Format.RGBA8888);
transparentMaskPixmap.setColor(Color.CLEAR);
transparentMaskPixmap.fill();
transparentMaskTexture = new Texture(transparentMaskPixmap);
transparentMaskSprite = new Sprite(transparentMaskTexture);
//Initialize main frame buffer
FrameBuffer.FrameBufferBuilder frameBufferBuilder = new FrameBuffer.FrameBufferBuilder(256, 240);
frameBufferBuilder.addBasicColorTextureAttachment(Pixmap.Format.RGBA8888);
mainFrameBuffer = frameBufferBuilder.build();
mainTextureRegion = new TextureRegion(mainFrameBuffer.getColorBufferTexture(), 0, 0,
256, 240);
mainTextureRegion.flip(false, true);
mainTextureRegion.getTexture().setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
//Initialize special frame buffer for foreground sprites so
//we can hide them with fake background sprites
foregroundSpritesFrameBuffer = frameBufferBuilder.build();
foregroundSpritesTextureRegion = new TextureRegion(foregroundSpritesFrameBuffer.getColorBufferTexture(), 0, 0,
256, 240);
foregroundSpritesTextureRegion.flip(false, true);
foregroundSpritesTextureRegion.getTexture().setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
//Initialize palette information
palettePixmap = new Pixmap(32, 1, Pixmap.Format.RGBA8888);
paletteTexture = new Texture(palettePixmap);
masterPalette = loadPalette("palette/nespalette.bmp", 1, 1, 32, 32, 16, 4);
}
示例9: inserted
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
@Override
public void inserted(int entityId, RenderSystem renderSystem) {
if (cameraBar == null) {
cameraBar = new OrthographicCamera(renderSystem.getLevelAssets().health_bar_gradient.getWidth(),
renderSystem.getLevelAssets().health_bar_gradient.getHeight());
uiCamera = new OrthographicCamera(UI_WIDTH, UI_HEIGHT);
}
RenderComponent render = renderSystem.getMapperRender().get(entityId);
PositionComponent position = renderSystem.getMapperPosition().get(entityId);
if (render.animations.size == 0) {
for (Map.Entry<String, RenderComponent.RenderTemplate.AnimationTemplate> entry : render.renderTemplate.animationTemplates.entrySet()) {
TextureRegion texture = renderSystem.getLevelAssets().get(entry.getValue().texture);
TextureRegion[][] tmp = texture.split(
+texture.getRegionWidth() / entry.getValue().frameColumns,
+texture.getRegionHeight() / entry.getValue().frameRows);
TextureRegion[] frames = new TextureRegion[entry.getValue().frameColumns * entry.getValue().frameRows];
int index = 0;
for (int i = 0; i < entry.getValue().frameRows; i++) {
for (int j = 0; j < entry.getValue().frameColumns; j++) {
frames[index++] = tmp[i][j];
}
}
render.animations.put(entry.getKey(), new Animation<>(entry.getValue().frameDuration, new Array<>(frames), entry.getValue().playMode));
render.stateTimes.put(entry.getKey(), 0f);
}
}
Decal decal = Decal.newDecal(render.width, render.height, render.getCurrentKeyFrame(renderSystem.getStateTime()), render.transparent);
decal.rotateX(renderSystem.getWorldDegree());
decal.setPosition(position.position.x, position.position.y, 0);
renderSystem.getDecalMap().put(entityId, decal);
FrameBuffer buffer = new FrameBuffer(Pixmap.Format.RGBA8888, UI_WIDTH, UI_HEIGHT, false);
Assets.LevelAssets levelAssets = renderSystem.getLevelAssets();
FrameBuffer healthBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, levelAssets.health_bar_gradient.getWidth(), levelAssets.health_bar_gradient.getHeight(), false);
TextureRegion healthBar = new TextureRegion(healthBuffer.getColorBufferTexture());
healthBar.flip(false, true);
FrameBuffer resourceBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, levelAssets.health_bar_gradient.getWidth(), levelAssets.health_bar_gradient.getHeight(), false);
TextureRegion resourceBar = new TextureRegion(resourceBuffer.getColorBufferTexture());
resourceBar.flip(false, true);
healthBars.put(entityId, healthBar);
resourceBars.put(entityId, resourceBar);
healthBuffers.put(entityId, healthBuffer);
resourceBuffers.put(entityId, resourceBuffer);
buffer.getColorBufferTexture().setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
renderSystem.getBuffers().put(entityId, buffer);
TextureRegion uiTextureRegion = new TextureRegion(buffer.getColorBufferTexture());
uiTextureRegion.flip(false, true);
Decal uiDecal = Decal.newDecal(1.8f, 1f, uiTextureRegion, true);
uiDecal.setPosition(position.position.x, position.position.y, 1);
renderSystem.getUiMap().put(entityId, uiDecal);
}
示例10: process
import com.badlogic.gdx.graphics.g2d.TextureRegion; //导入方法依赖的package包/类
/**
* Updates the {@link gg.al.character.Character} {@link Decal}, and uses the currently set animation from the {@link RenderComponent}.<br>
* Also redraws the health and resource bars, and updates their position accordingly.
*
* @param entityId the {@link gg.al.character.Character} entity id
* @param renderSystem the delegating {@link RenderSystem}
*/
@Override
public void process(int entityId, RenderSystem renderSystem) {
PhysicComponent physic = renderSystem.getMapperPhysic().get(entityId);
RenderComponent render = renderSystem.getMapperRender().get(entityId);
StatComponent stats = renderSystem.getMapperStats().get(entityId);
CharacterComponent character = renderSystem.getMapperCharacterComponent().get(entityId);
Decal decal = renderSystem.getDecalMap().get(entityId);
float stateTime = renderSystem.getStateTime();
if (character != null && render.isInState(ATTACK)) {
stateTime = render.animations.get(PlayerRenderState.ATTACK.name()).getAnimationDuration() * character.getRenderMultiplicator();
} else if (character != null && render.isInAnyState(
ABILITY_1, ABILITY_2, ABILITY_3, ABILITY_4, TRAIT
)) {
stateTime = render.stateTimes.get(render.renderState);
stateTime += renderSystem.getDelta();
if (render.animations.get(render.renderState).isAnimationFinished(stateTime)) {
render.stateTimes.put(render.renderState, 0f);
render.setRenderState(IDLE);
} else
render.stateTimes.put(render.renderState, stateTime);
}
TextureRegion region = render.getCurrentKeyFrame(stateTime);
region.flip(region.isFlipX() ^ render.flipX, region.isFlipY() ^ render.flipY);
decal.setTextureRegion(region);
RenderComponent.RenderTemplate.AnimationTemplate template = render.getCurrentAnimation();
decal.setWidth(template.width);
decal.setHeight(template.height);
decal.setPosition(physic.body.getPosition().x, physic.body.getPosition().y, decal.getZ());
SpriteBatch shaderBatch = renderSystem.getShaderBatch();
ShaderProgram shader = renderSystem.getGradientShader();
drawToBuffer(healthBuffers.get(entityId), healthBarColor, renderSystem.getLevelAssets().health_bar_gradient,
stats.getRuntimeStat(StatComponent.RuntimeStat.health) / stats.getCurrentStat(StatComponent.BaseStat.maxHealth),
shaderBatch, shader, cameraBar.combined);
drawToBuffer(resourceBuffers.get(entityId), resourceBarColor, renderSystem.getLevelAssets().health_bar_gradient,
stats.getRuntimeStat(StatComponent.RuntimeStat.resource) / stats.getCurrentStat(StatComponent.BaseStat.maxResource),
shaderBatch, shader, cameraBar.combined);
FrameBuffer buffer = renderSystem.getBuffers().get(entityId);
buffer.begin();
AL.graphics.getGL20().glClearColor(0, 0, 0, 0);
AL.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT);
renderSystem.getSpriteBatch().setProjectionMatrix(uiCamera.combined);
renderSystem.getSpriteBatch().begin();
//renderSystem.getFont().draw(renderSystem.getSpriteBatch(), String.format("%1.0f", stats.getRuntimeStat(StatComponent.RuntimeStat.actionPoints)), 0, buffer.getHeight());
renderSystem.getSpriteBatch().draw(resourceBars.get(entityId), 50 - UI_WIDTH / 2, -UI_HEIGHT / 2 + RESOURCE_OFFSET, 175, 75 / 2);
renderSystem.getSpriteBatch().draw(healthBars.get(entityId), 50 - UI_WIDTH / 2, -30, 200, 100 / 2);
renderSystem.getFont().draw(renderSystem.getSpriteBatch(), String.format("%1.0f", stats.getRuntimeStat(StatComponent.RuntimeStat.actionPoints)),
-UI_WIDTH / 2 - 4, 20);
renderSystem.getSpriteBatch().end();
buffer.end();
Decal uiDecal = renderSystem.getUiMap().get(entityId);
uiDecal.setPosition(physic.body.getPosition().x, physic.body.getPosition().y + decal.getHeight() / 2, uiDecal.getZ());
}