Hello
I want to create a “sprite” whose rotation is accelerating and when I press button (‘A’ for example) acceleration slows down.
This is what I created:
private void update()
{
if(1 < 2)
{
rotation=1;
time += Gdx.graphics.getDeltaTime();
rotation *= time * temp;
System.out.println("time " + time);
System.out.println("rotation " + rotation);
System.out.println("temp " + temp);
if(rotation > 360)
{
time = 0;
temp += 30;
}
else if(Gdx.input.isKeyPressed(Keys.A))
{
rotation -= 4.0f;
time = 0;
temp /= 1.01;
}
}
}
and render:
batch.draw(kreska2, Gdx.graphics.getWidth()/2-kreska.getWidth()/2, Gdx.graphics.getHeight()/2, 0, 0, kreska.getWidth(), kreska.getHeight(), 1, 1, rotation);
- Iis it designed in the correct way? Or it is piece of…?
- How to create a smooth acceleration?
- (It is main question) Right now when I press ‘A’ rotation speed will slow down but angle will be set to 0. When I will just use ‘rotation -= 4.0f;’ to slow down rotation, that the angle will go back several degrees. How to handle this topic?