How to flip sprites using bunnymark.lua

Hi, I’m having a problem using the bunnymark.lua code.

Probably a silly question - how do I flip a sprite when its stored using this code?
I know its probably a simple addressing code issue, but I can’t figure it out.
Here is my code.
I’m probably not addressing it correctly here in the factory object.
=>sprite.set_hflip(“bunny#sprite”, vX < 0)

function update(self, dt)
bunnymark.update()
local bunnies = bunnymark.bunnies

local target =go.get_position("/player") 

for i=#bunnymark.bunnies,1,-1 do
	local bunny = bunnies[i]
	local p = bunny.position
	
	local dirX = target.x - p.x
	local dirY = target.y - p.y
	local vX = math.abs(bunny.velocity)
	local vY = vX 

	if (dirX<0) then vX = -vX  end
	if (dirX==0) then vX = 0 end
	if (dirY<0) then vY = -vY end
	if (dirY==0) then vY = 0 end

	p.x = p.x + vX  * dt
	p.y = p.y + vY  * dt

	--Make sure I face the right way (NOT WORKING!?)
	sprite.set_hflip("bunny#sprite", vX < 0)
			

	go.set_position(p, bunny.id)

end

end

SOLVED: Sorry I’ve found the solution.

The correct addressing should be…

sprite.set_hflip(bunny.id, dirX < 0)

It all works now :slight_smile: