I have a sprite like this.
I want to draw this sprite in such a way that sprite is growing from bottom to top, using sprite batch on tap.for that,I have written the following code:
if (MyInputProcessor.isTap)
{
Sprite stickSprite = new Sprite(stickTexture);
stickSprite.setPosition(stick.getX(),stick.getY());
for(float n=0;n<100;n++)
{
float i = 0.01f * n;
batch.draw(
stickSprite.getTexture(),
stick.getX(),
stick.getY(),
stickSprite.getWidth() / 2,
stickSprite.getHeight() / 2,
stickSprite.getWidth(),
stickSprite.getHeight()*i, //multiplying with height
stickSprite.getScaleX(),
stickSprite.getScaleY(),
0 ,
stickSprite.getRegionX(),
stickSprite.getRegionY(),
stickSprite.getRegionWidth(),
stickSprite.getRegionHeight(),
false,
false);
}
MyInputProcessor.isTap = false;
}
Here the i value increments but not taking effect in the code to scale. Whats wrong with the code?
I tried this also:
private void drawStick() {
Sprite stickSprite = new Sprite(stickTexture);
if (MyInputProcessor.isTap)
{
stickSprite.setPosition(stick.getX(),stick.getY());
for(float n=0;n<=100;n++)
{
float i = 0.01f * n;
stickSprite.setSize(stickSprite.getWidth(),stickSprite.getHeight()+i);
}
}
stickSprite.draw(batch);
But rendering full sprite only.