ScaleTo does not work in Libgdx

I am trying to scale my Actor using actions. But that does not work. I just want my actor to increase / decrease its size over time.

The actor will just wait for the 2 second duration I gave ScaleTo . It moves correctly based on the MoveTo action I gave it.

 public class SpriteTest extends Actor { private Sprite sprite; private TextureAtlas atlas; Rectangle boundsd = new Rectangle(); public SpriteTest(FirstGame game) { //super(game); Gdx.app.log( FirstGame.LOG, "spritetest costructor" ); atlas = new TextureAtlas(Gdx.files.internal("pages-info.atlas")); sprite = atlas.createSprite("Plus"); } public void draw(SpriteBatch batch,float parentAlpha) { batch.draw(sprite, x, y); } // We are adding the actor to the stage in another class public class LevelScreen extends AbstractScreen { private Jumper2D jumper2d; SpriteTest obstacled = new SpriteTest(game); public LevelScreen(FirstGame game) { super(game); } @Override protected boolean isGameScreen() { return true; } @Override public void show() { super.show(); stage.addActor(obstacled); obstacled.action (Forever.$ (Sequence.$ (ScaleTo.$(1.4f, 1.4f, 2),(MoveTo.$(100,120, 3f) )) )); jumper2d = Jumper2D.create(getAtlas()); stage.addActor(jumper2d); stage.draw(); } public void render () { Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); } } 

Any help is appreciated

+4
source share
1 answer

Your draw() method for SpriteTest ignores any scale or rotation settings on the Actor . You need to draw the sprite scaled / rotated / size accordingly. (You may also need to set the Actor x, y, width and height --- see setBounds )

 public void draw(SpriteBatch batch, float parentAlpha) { final Color c = getColor(); batch.setColor(cr, cg, cb, ca * parentAlpha); batch.draw(sprite, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation()); } 
+8
source

All Articles