Answer the question
In order to leave comments, you need to log in
Why is the sprite twitching?
Hello!
Wrote a function that calculates the coordinates of a sprite that moves in a circle.
Well, the formula is elementary
x = x0 + R* cos (t*a+a0)
y = y0 + R *sin (t*a+a0)
The function looks like this
public void pointDefinition(float delta){
sprite.setPosition(Gdx.graphics.getWidth()/2+(85*(float)Math.cos(i*delta)), Gdx.graphics.getHeight()/2+(85*(float)Math.sin(i*delta)));
i = i + 0.5;
}
Answer the question
In order to leave comments, you need to log in
And so, the answer was on the surface
. All that was needed was not to multiply delta by i, but to add it
As they say, "thanks to stackoverflow for my career" (c)
public void pointDefinition(float delta)
{
sprite.setPosition((Gdx.graphics.getWidth() / 2) + (85 * (float)Math.cos(i)), (Gdx.graphics.getHeight() / 2) + (85 * (float)Math.sin(i)));
i = i + delta;
}
https://docs.oracle.com/javase/7/docs/api/java/lan...
Intuition tells me that this will help.
public void pointDefinition(float delta){
float angle = Math,ToRadians(i*delta);
sprite.setPosition(Gdx.graphics.getWidth()/2+(85*(float)Math.cos(angle)), Gdx.graphics.getHeight()/2+(85*(float)Math.sin(angle) ));
i = i + 0.5;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question