Rotating after flipping sprite causes the sprite to rotate wrong

Right now I have a sprite that I rotate and it works fine until I flip it, then it rotates all wrong. Is there something I have to do after I call setImageFlip() so that it rotates the same but just with the image flipped? Or any advice on how to fix this?
(I am also using Whitebrim's AnimatedSprite for the head sprite)

You can see in the gif the player serving has the expected head rotation. When the player on the right goes to spike, the flipped head sprite rotates unexpectedly.

function AimBodyParts:init(character, headOffsetX, headOffsetY, armOffsetX, armOffsetY)
    local head_img ='Images/Characters/fire_girl-aiming_head')
    local arm_img ='Images/Characters/fire_girl-aiming_arm')
    self.character = character
    self.headOffsetX = headOffsetX
    self.headOffsetY = headOffsetY

    self.rotation = 0
    self.flipped = false

    -- Animated head sprite
    self.head_sprite =
    self.head_sprite:addState('spike', 1, 4, {tickStep = 5})
    self.head_sprite:setZIndex(character:getZIndex() + 1)
    self.head_sprite:setCenter(0.5, 1)
    self.head_sprite:moveTo(self.character.x + self.headOffsetX, self.character.y + self.headOffsetY)

    if character.x > 200 then


function AimBodyParts:flipSprites()
            name = "default",
            flip = gfx.kImageFlippedX
    self.headOffsetX = -self.headOffsetX
    self.flipped = true

function AimBodyParts:update()

    local aim = math.atan(self.character.ball.y - self.arm_sprite.y, self.character.ball.x - self.arm_sprite.x)
    self.rotation = math.deg(aim)
    if self.flipped then
        self.rotation = 180 - self.rotation

1 Like

Might be off the mark, but self.rotation = 180 - self.rotation seems wrong.
I suspect you want one of:
self.rotation *= -1
self.rotation += 180
self.rotation -= 180
But without actually running it I can’t be sure.

Appreciate the help. The code uses 180 - self.rotation to adjust for the flipped sprite so that the back of the head isn't facing the ball.
The issue I'm having is that the character head is looking at the ball properly, but appearing to rotate around a different pivot point. The un-flipped head (character serving on the left) is rotating properly around its center point of (0.5, 1) but the spiking character on the right does not appear to rotate around that same center point.

Another developer has tried something similar and has told me that this appears to be a bug in the sdk.

If anyone has any other insight please let me know, but as for now I'll just have to make a set of flipped heads and import them

1 Like

What happens if you re-set the centre point after setting the new rotation?

Same thing, still rotates incorrectly.

Have tagged this as a bug report

1 Like

Sounds good, thank you!


Yeah, it’s a bug.
Left is sprite with center at 0.5, 1, rotating clockwise
Right is flipped sprite (flipX) with center at 0.5, 1, rotating anti-clockwise.


I noticed that too, for me even a simple 90 degree rotation distorts the source image

im rotating externlly for now

That's what I am doing now as well. Although I saw that 2.5.0 released today and saw some stuff about rotations in there so I was going to see if something for this issue got pushed through.