/** boolean parameters x,y are not setting a state, but performing a flip * @param x perform horizontal flip * @param y perform vertical flip */ public void flip (boolean x, boolean y) { super.flip(x, y); float[] vertices = Sprite.this.vertices; if (x) { float temp = vertices[U1]; vertices[U1] = vertices[U3]; vertices[U3] = temp; temp = vertices[U2]; vertices[U2] = vertices[U4]; vertices[U4] = temp; } if (y) { float temp = vertices[V1]; vertices[V1] = vertices[V3]; vertices[V3] = temp; temp = vertices[V2]; vertices[V2] = vertices[V4]; vertices[V4] = temp; } }
/** boolean parameters x,y are not setting a state, but performing a flip * @param x perform horizontal flip * @param y perform vertical flip */ public void flip (boolean x, boolean y) { super.flip(x, y); float[] vertices = Sprite.this.vertices; if (x) { float temp = vertices[U1]; vertices[U1] = vertices[U3]; vertices[U3] = temp; temp = vertices[U2]; vertices[U2] = vertices[U4]; vertices[U4] = temp; } if (y) { float temp = vertices[V1]; vertices[V1] = vertices[V3]; vertices[V3] = temp; temp = vertices[V2]; vertices[V2] = vertices[V4]; vertices[V4] = temp; } }
@Override /** Flips the region, adjusting the offset so the image appears to be flip as if no whitespace has been removed for packing. */ public void flip (boolean x, boolean y) { super.flip(x, y); if (x) offsetX = originalWidth - offsetX - getRotatedPackedWidth(); if (y) offsetY = originalHeight - offsetY - getRotatedPackedHeight(); }
@Override /** Flips the region, adjusting the offset so the image appears to be flip as if no whitespace has been removed for packing. */ public void flip (boolean x, boolean y) { super.flip(x, y); if (x) offsetX = originalWidth - offsetX - getRotatedPackedWidth(); if (y) offsetY = originalHeight - offsetY - getRotatedPackedHeight(); }
public TiledMapTileMapObject (TiledMapTile tile, boolean flipHorizontally, boolean flipVertically) { this.flipHorizontally = flipHorizontally; this.flipVertically = flipVertically; this.tile = tile; TextureRegion textureRegion = new TextureRegion(tile.getTextureRegion()); textureRegion.flip(flipHorizontally, flipVertically); setTextureRegion(textureRegion); }
public TiledMapTileMapObject (TiledMapTile tile, boolean flipHorizontally, boolean flipVertically) { this.flipHorizontally = flipHorizontally; this.flipVertically = flipVertically; this.tile = tile; TextureRegion textureRegion = new TextureRegion(tile.getTextureRegion()); textureRegion.flip(flipHorizontally, flipVertically); setTextureRegion(textureRegion); }
debugTexture = new Texture(debugPixmap); debugTextureRegion = new TextureRegion(debugTexture); debugTextureRegion.flip(false, true);
m_fboRegion.flip(false, true);
@Override public void create () { texture = new Texture(Gdx.files.internal("data/walkanim.png")); TextureRegion[] leftWalkFrames = TextureRegion.split(texture, 64, 64)[0]; Array<TextureRegion> rightWalkFrames = new Array(TextureRegion.class); for (int i = 0; i < leftWalkFrames.length; i++) { TextureRegion frame = new TextureRegion(leftWalkFrames[i]); frame.flip(true, false); rightWalkFrames.add(frame); } leftWalk = new Animation<TextureRegion>(0.25f, leftWalkFrames); rightWalk = new Animation<TextureRegion>(0.25f, rightWalkFrames); TextureRegion[] rightRegions = rightWalk.getKeyFrames(); // testing backing array type TextureRegion firstRightRegion = rightRegions[0]; Gdx.app.log("AnimationTest", "First right walk region is " + firstRightRegion.getRegionWidth() + "x" + firstRightRegion.getRegionHeight()); cavemen = new Caveman[100]; for (int i = 0; i < 100; i++) { cavemen[i] = new Caveman((float)Math.random() * Gdx.graphics.getWidth(), (float)Math.random() * Gdx.graphics.getHeight(), Math.random() > 0.5 ? true : false); } batch = new SpriteBatch(); fpsLog = new FPSLogger(); }
@Override public void create () { // a bitmap font to draw some text, note that we // pass true to the constructor, which flips glyphs on y font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), true); // a texture region, note the flipping on y again region = new TextureRegion(new Texture("data/badlogic.jpg")); region.flip(false, true); // a texture atlas, note the boolean atlas = new TextureAtlas(Gdx.files.internal("data/pack"), true); // a sprite, created from a region in the atlas sprite = atlas.createSprite("badlogicsmall"); sprite.setPosition(0, 0); // a sprite batch with which we want to render batch = new SpriteBatch(); // a camera, note the setToOrtho call, which will set the y-axis // to point downwards camera = new OrthographicCamera(); camera.setToOrtho(true); // a stage which uses our y-down camera and a simple actor (see MyActor below), // which uses the flipped region. The key here is to // set our y-down camera on the stage, the rest is just for demo purposes. stage = new Stage(); stage.getViewport().setCamera(camera); image = new MyActor(region); image.setPosition(100, 100); stage.addActor(image); // finally we write up the stage as the input process and call it a day. Gdx.input.setInputProcessor(stage); }
public void create () { ShaderProgram.pedantic = false; /* * shader = new ShaderProgram(Gdx.files.internal("data/shaders/default.vert").readString(), Gdx.files.internal( * "data/shaders/depthtocolor.frag").readString()); if (!shader.isCompiled()) { Gdx.app.log("EdgeDetectionTest", * "couldn't compile scene shader: " + shader.getLog()); } */ batchShader = new ShaderProgram(Gdx.files.internal("data/shaders/batch.vert").readString(), Gdx.files.internal( "data/shaders/convolution.frag").readString()); if (!batchShader.isCompiled()) { Gdx.app.log("EdgeDetectionTest", "couldn't compile post-processing shader: " + batchShader.getLog()); } ObjLoader objLoader = new ObjLoader(); scene = objLoader.loadModel(Gdx.files.internal("data/scene.obj")); sceneInstance = new ModelInstance(scene); modelBatch = new ModelBatch(); fbo = new FrameBuffer(Format.RGB565, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(0, 0, 10); cam.lookAt(0, 0, 0); cam.far = 30; batch = new SpriteBatch(); batch.setShader(batchShader); fboRegion = new TextureRegion(fbo.getColorBufferTexture()); fboRegion.flip(false, true); logger = new FPSLogger(); calculateOffsets(); }
float xPos = tmtObject.getX(); float yPos = tmtObject.getY(); textureRegion.flip(tmtObject.isFlipHorizontally(), tmtObject.isFlipVertically()); batch.draw(textureRegion, xPos, yPos, tmtObject.getOriginX() * scaleX, tmtObject.getOriginY() * scaleY, textureRegion.getRegionWidth() * scaleX, textureRegion.getRegionHeight() * scaleY, 1f, 1f, rotation); textureRegion.flip(tmtObject.isFlipHorizontally(), tmtObject.isFlipVertically()); batch.end(); } else if (mapObject instanceof EllipseMapObject) {
String textureFile = "data/textures.txt"; atlas = new TextureAtlas(Gdx.files.internal(textureFile), Gdx.files.internal("data")); // Let's flip all the regions. Required for y=0 is TOP Array<AtlasRegion> tr = atlas.getRegions(); for (int i = 0; i < tr.size; i++) { TextureRegion t = tr.get(i); t.flip(false, true); }
TextureRegion image = new TextureRegion(texture1); TextureRegion imageFlipped = new TextureRegion(image); imageFlipped.flip(true, true); TextureRegion image2 = new TextureRegion(texture2);
public static TextureRegion flipRegion(TextureRegion region, boolean flipX, boolean flipY) { if (flipX || flipY) { TextureRegion flippedRegion = new TextureRegion(region); flippedRegion.flip(flipX, flipY); return flippedRegion; } return region; }
Array<TextureRegion> monkeyWalkRightRegions = AssetsManager.getAsset("animations/monkeywalk.txt", TextureAtlas.class).getRegions(); monkeyAnimRight = new Animation(1/10.0f, monkeyWalkRightRegions); monkeyAnimRight.setPlayMode(Animation.PlayMode.LOOP_REVERSED); Array<TextureRegion> monkeyWalkLeftRegions = new Array<TextureRegion>(); //copy and then flip each region and add it to the new array for(TextureRegion keyFrame : monkeyWalkRightRegions ) { TextureRegion region = new TextureRegion(keyFrame); //copy of region created region.flip(true, false); monkeyWalkLeftRegions.add(region); } monkeyAnimLeft = new Animation(1/20.0f, monkeyWalkLeftRegions );
@Override /** Flips the region, adjusting the offset so the image appears to be flip as if no whitespace has been removed for packing. */ public void flip (boolean x, boolean y) { super.flip(x, y); if (x) offsetX = originalWidth - offsetX - getRotatedPackedWidth(); if (y) offsetY = originalHeight - offsetY - getRotatedPackedHeight(); }
public TiledMapTileMapObject (TiledMapTile tile, boolean flipHorizontally, boolean flipVertically) { this.flipHorizontally = flipHorizontally; this.flipVertically = flipVertically; this.tile = tile; TextureRegion textureRegion = new TextureRegion(tile.getTextureRegion()); textureRegion.flip(flipHorizontally, flipVertically); setTextureRegion(textureRegion); }
@Override public void resize(int width, int height) { this.width = width; this.height = height; if (frameBuffer != null) frameBuffer.dispose(); frameBuffer = new FrameBuffer(Pixmap.Format.RGB565, width, height, false); bufferTexture = new TextureRegion(frameBuffer.getColorBufferTexture()); bufferTexture.flip(false, true); }
/** * 截图 */ public TextureRegion getFullTextrueRegion() { Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Texture texture = new Texture(pixmap); TextureRegion region = new TextureRegion(texture); region.flip(false, true); return region; }