I have a sprite, which I draw with:
sprite.draw(spriteBatch);
This works.... I have two spites showing the same, but with different resolution...
Let's say x1 = h:100px, x2= h:200px
In the very wrapper class of the sprite I have a method like this:
public static void setSclae(float newScale, Sprite sprite) {
// sprite.scale(newScale - sprite.getScaleX());
sprite.setScale(newScale);
}
(I tried both, both didn't work) Documentation: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/Sprite.html#setScale(float)
On creation of the wrapper class I call the function like this:
setScale(setSide/(setWidth ? this.sprite.getBoundingRectangle().width : this.sprite.getBoundingRectangle().height));
setWidth => boolean (Do you want to set the height or the width??) this. sprite is a sprite. Origin @(0,0)
The problem is: I want to set the height, no matter which sprite comes in, to 50px...
For x1: setScale(50/100) -> 0.5f
For x2: setScale(50/200) -> 0.25f
Why the hell does this piese of code not work??
Thanks for helping out
Yours,
Florian
PS: Here the constructor of the wrapper class:
public Drawable(Sprite sprite, Vector2 position, Anchor anchor, float setSide, boolean setWidth, boolean flipH, boolean flipV) {
this.sprite = new Sprite(sprite);
this.sprite.setOrigin(0, 0);
setPosition(anchor, position.x, position.y);
setScale(setSide / (setWidth ? this.sprite.getBoundingRectangle().width : this.sprite.getBoundingRectangle().height));
this.sprite.flip(flipV, flipH);
}