I want four sprites to orbit a single origin point. But if I use like this

    sprite_p1_avatar = new Sprite(dummyText);
    sprite_p1_avatar.setPosition(200, 200);
    sprite_p1_avatar.setOrigin(100, 100);

    sprite_p2_avatar = new Sprite(dummyText);
    sprite_p2_avatar.setPosition(300, 300);
    sprite_p2_avatar.setOrigin(100, 100);

    sprite_p3_avatar = new Sprite(dummyText);
    sprite_p3_avatar.setPosition(400, 400);
    sprite_p3_avatar.setOrigin(100, 100);

    sprite_p4_avatar = new Sprite(dummyText);
    sprite_p4_avatar.setPosition(500, 500);
    sprite_p4_avatar.setOrigin(100, 100);

    sprite_p1_avatar.rotate(40 * delta);


    sprite_p2_avatar.rotate(40 * delta);

    sprite_p3_avatar.rotate(40 * delta);

    sprite_p4_avatar.rotate(40 * delta);

the sprite get inverted while revolving, as these sprites are profile pictures of users I want them to stay straight while orbiting at every point. Is there any way to move the sprites along a circular path without rotating.


This is rather simple approach. To keep it pointing up, it'd be easier to translate sprites on your own.

  • Calculate current angle of your rotation each frame
  • Then calculate offset from origin (See this link for maths)
  • Add offset to origin and set your position

    public static Vector2 getCurrentPosition(float degrees, Vector2 origin, float radius) {
        //pre-calculate sin and cos
        float radians = degrees * MathUtils.degreesToRadians;
        float sin = MathUtils.sin(radians);
        float cos = MathUtils.cos(radians);
        float offsetX = cos * radius;
        float offsetY = sin * radius;
        float currentX = origin.x + offsetX;
        float currentY = origin.y + offsetY;
        //return your position or set it here, nevermind,  whatever suits you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.