Make sprite wobble

For the menu in my little game I need to make a sprite wobble using tween…

But it’s just flying off the screen when I rotate.

Could someone give an example of how to tween a sprite wobble please?

Thanks!

Here’s a class that creates a wobbling sprite:

--# WobbleSprite
WobbleSprite = class()

function WobbleSprite:init(tex, pos, wobbleAmount)
    -- you can accept and set parameters here
    self.texture = tex
    self.pos = pos or vec2(0,0)
    self.wobbleAmount = wobbleAmount or 5
    self.angle = -self.wobbleAmount
    
    tween(0.2, self, {angle = self.wobbleAmount}, 
          { easing = tween.easing.quadInOut, 
            loop = tween.loop.pingpong } )
end

function WobbleSprite:draw()
    pushMatrix()
    pushStyle()
    
    translate(self.pos.x, self.pos.y)
    rotate(self.angle)
    
    spriteMode(CENTER)
    sprite(self.texture, 0, 0)
    
    popStyle()
    popMatrix()
end


--# Main

function setup()    
    -- Create the sprite
    wobble = WobbleSprite("Cargo Bot:Clear Button")
end

function draw()

    background(40, 40, 50)
    strokeWidth(5)

    -- Center the sprite
    wobble.pos = vec2( WIDTH/2, HEIGHT/2 )

    -- Do your drawing here
    wobble:draw()
end


```

Tried it, perfect!! Thanks