java - Sprite resize libGDX -


After

I have a sprite, which I have drew with:

  sprite.draw ( Spritebatch);  

This works ... I have two spots to look the same, but with different resolutions ...

Suppose x1 = h: 100px, x2 = h: 200px

Sprite I have a method like this in a very covered category:

  public static void setSclae (name newScale, Sprite Sprite) {// Sprite. Scale (Newcastle - Sp .getScaleX ()); Sprite.setScale (newScale); }  

(I tried both, both did not work) Documentation:

On the creation of the cover 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 height or width ??) This phantom is a phantom original @ (0,0)

The problem is : I want to set the height, no matter which phantom comes in 50px ...

x1: setScale (50/100) -> 0.5f

for x2 : SetScale (50/200) -> 0.25f

Why the hell code does not work ??

Florian

PS: Creators of the wrapper class here:

Thank you for helping

/ P> Drawable {this.sprite = new Sprite (Sprite) (Sprite Sprite, Vector2 Position, Anchor anchor, setSide, Boolean setWidth, Boolean FlipH, Boolean FlipV floats); This. Sprite.setOrigin (0, 0); SetPosition (anchor, position.x, position.y); SetScale (setSide / (setWidth? It. Sprite.getBoundingRectangle (). Width: this.sprite.getBoundingRectangle (). Height)); This. Sprite.flip (flip v, flip h); }

I will answer myself. How did I solve it? I have implemented my own "Sprites" class using the Taxitiar region. You do not need all the Pastebin: IGameObject interface folks [You do not need the INNectectt interface .... Import com.badlogic.gdx.graphics.g2d.SpriteBatch; Public Interface IGameObject {public static enum anchor {TopLeft, MiddleLeft, LowLeft, TopMiddle, MiddleMiddle, LowMiddle, Topright, MiddleRight, LowRight} Public Zero Update (GameTime.GameTimeArgs gameTimeArgs); Public Zero Draw (Spritebatch Spreadbatch); Public Zero Set Status (Anchor A, Float X, Float Y); Public Zero Setcell (Float Newcastle); Public string toasting ();


Comments