public void draw(SpriteBatch batch) { if (background != null) { batch.disableBlending(); batch.setProjectionMatrix(camera.calculateParallaxMatrix(1, 1)); batch.begin(); float x = 0; for (AtlasRegion tile : background) { batch.draw(tile, x, 0f); x += tile.getRegionWidth(); } batch.end(); batch.enableBlending(); } // draw layers from bottom to top for (int i = layers.size() - 1; i >= 0; i--) { SceneLayer layer = layers.get(i); batch.setProjectionMatrix(camera.calculateParallaxMatrix(layer.getParallaxMultiplier(), 1)); batch.begin(); layer.draw(batch); batch.end(); } }
width += background.get(i).getRegionWidth();
batch.draw(charIcon, getX() - charIcon.getRegionWidth() * scale, getY(), charIcon.getRegionWidth() * scale, charIcon.getRegionHeight() * scale);
powerup.position.x - Constants.POWERUP_CENTER.x, powerup.position.y - Constants.POWERUP_CENTER.y, Assets.instance.powerupAssets.powerup.getRegionWidth(), Assets.instance.powerupAssets.powerup.getRegionHeight() );
@Override public void render() { Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); // Don't do this! This results in drawing the entire texture atlas, not just the region you're interested in // batch.draw(standingRight.getTexture(), 0, 0); // TODO: Draw the standing right AtlasRegion // Hint, you need to use the somewhat horrific version of draw with signature: // 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) batch.draw( standingRight.getTexture(), 0, 0, 0, 0, standingRight.getRegionWidth(), standingRight.getRegionHeight(), 1, 1, 0, standingRight.getRegionX(), standingRight.getRegionY(), standingRight.getRegionWidth(), standingRight.getRegionHeight(), false, false); batch.end(); }
(int) (r.getRegionHeight() * 200f / r.getRegionWidth()));
public AtlasSprite (AtlasRegion region) { this.region = new AtlasRegion(region); originalOffsetX = region.offsetX; originalOffsetY = region.offsetY; setRegion(region); setOrigin(region.originalWidth / 2f, region.originalHeight / 2f); int width = region.getRegionWidth(); int height = region.getRegionHeight(); if (region.rotate) { super.rotate90(true); super.setBounds(region.offsetX, region.offsetY, height, width); } else super.setBounds(region.offsetX, region.offsetY, width, height); setColor(1, 1, 1, 1); }
private Sprite newSprite (AtlasRegion region) { if (region.packedWidth == region.originalWidth && region.packedHeight == region.originalHeight) { if (region.rotate) { Sprite sprite = new Sprite(region); sprite.setBounds(0, 0, region.getRegionHeight(), region.getRegionWidth()); sprite.rotate90(true); return sprite; } return new Sprite(region); } return new AtlasSprite(region); }
private void normalizeHorizontalPatches(ImageModel imageModel, TextureAtlas.AtlasRegion ninePatchRegion) { int totalPatchWidth = imageModel.getNinepatchOffsetLeft() + imageModel.getNinepatchOffsetRight(); if(totalPatchWidth >= ninePatchRegion.getRegionWidth()) { int usableAreaWidth = calculateMinUsableAreaSize(ninePatchRegion.getRegionWidth()); imageModel.setNinepatchOffsetLeft(calculateNewPatchSize(usableAreaWidth, imageModel.getNinepatchOffsetLeft(), totalPatchWidth)); imageModel.setNinepatchOffsetRight(calculateNewPatchSize(usableAreaWidth, imageModel.getNinepatchOffsetRight(), totalPatchWidth)); } }
public AtlasSprite (AtlasRegion region) { this.region = new AtlasRegion(region); originalOffsetX = region.offsetX; originalOffsetY = region.offsetY; setRegion(region); setOrigin(region.originalWidth / 2f, region.originalHeight / 2f); int width = region.getRegionWidth(); int height = region.getRegionHeight(); if (region.rotate) { super.rotate90(true); super.setBounds(region.offsetX, region.offsetY, height, width); } else super.setBounds(region.offsetX, region.offsetY, width, height); setColor(1, 1, 1, 1); }
public AtlasSprite (AtlasRegion region) { this.region = new AtlasRegion(region); originalOffsetX = region.offsetX; originalOffsetY = region.offsetY; setRegion(region); setOrigin(region.originalWidth / 2f, region.originalHeight / 2f); int width = region.getRegionWidth(); int height = region.getRegionHeight(); if (region.rotate) { super.rotate90(true); super.setBounds(region.offsetX, region.offsetY, height, width); } else super.setBounds(region.offsetX, region.offsetY, width, height); setColor(1, 1, 1, 1); }
private Sprite newSprite (AtlasRegion region) { if (region.packedWidth == region.originalWidth && region.packedHeight == region.originalHeight) { if (region.rotate) { Sprite sprite = new Sprite(region); sprite.setBounds(0, 0, region.getRegionHeight(), region.getRegionWidth()); sprite.rotate90(true); return sprite; } return new Sprite(region); } return new AtlasSprite(region); }
private Sprite newSprite (AtlasRegion region) { if (region.packedWidth == region.originalWidth && region.packedHeight == region.originalHeight) { if (region.rotate) { Sprite sprite = new Sprite(region); sprite.setBounds(0, 0, region.getRegionHeight(), region.getRegionWidth()); sprite.rotate90(true); return sprite; } return new Sprite(region); } return new AtlasSprite(region); }