Skip to main content
added 240 characters in body
Source Link

EDIT: You need to separe sprite's initialization and display

  1. Make your sprite ONE time in your create method for example
  2. Update your sprite's height on tap
  3. Draw your sprite in your render method

Your code won't do what you want because you make a new sprite at every tap. You want to have a single sprite which you resize in height at every tap.

You should have something like this

// On tap
stickSprite.setSize(stickSprite.getWidth(), stickSprite.getHeight() + addValue);

This way you could draw your sprite easier like that

// On draw
stickSprite.draw(batch);

The setSize will resize your texture to the size you tell him. It will do it perfectly for your unicolor texture.

Hope it helps

Your code won't do what you want because you make a new sprite at every tap. You want to have a single sprite which you resize in height at every tap.

You should have something like this

// On tap
stickSprite.setSize(stickSprite.getWidth(), stickSprite.getHeight() + addValue);

This way you could draw your sprite easier like that

// On draw
stickSprite.draw(batch);

The setSize will resize your texture to the size you tell him. It will do it perfectly for your unicolor texture.

Hope it helps

EDIT: You need to separe sprite's initialization and display

  1. Make your sprite ONE time in your create method for example
  2. Update your sprite's height on tap
  3. Draw your sprite in your render method

Your code won't do what you want because you make a new sprite at every tap. You want to have a single sprite which you resize in height at every tap.

You should have something like this

// On tap
stickSprite.setSize(stickSprite.getWidth(), stickSprite.getHeight() + addValue);

This way you could draw your sprite easier like that

// On draw
stickSprite.draw(batch);

The setSize will resize your texture to the size you tell him. It will do it perfectly for your unicolor texture.

Hope it helps

Source Link

Your code won't do what you want because you make a new sprite at every tap. You want to have a single sprite which you resize in height at every tap.

You should have something like this

// On tap
stickSprite.setSize(stickSprite.getWidth(), stickSprite.getHeight() + addValue);

This way you could draw your sprite easier like that

// On draw
stickSprite.draw(batch);

The setSize will resize your texture to the size you tell him. It will do it perfectly for your unicolor texture.

Hope it helps