Changing the origin of a sprite (SOLVED)


Due to the origin of the sprite, when using sprite.set_hflip("#sprite", self.last_horiz == -1), the sprite flips all the way to the other side, completely out of the collision box. Is there any way to change the origin of rotation? Or is that feature still unimplemented?

If it still is unimplemented, is there any way to fix this issue with the current tools?

No way of changing them in Defold.
You can

  • rotate the object 180 in the y axis.
  • Go to GIMP -> Image ->Autocrop image to remove the excess transparent portion of the image and then use it.

Use collections instead of GOs then use collection factory instead of game object factory. Then you can parents GOs to each other in the collection and use them as pivots for sprites more easily.

You can utilize

local s = vmath.vector3(-1.0, 1.0, 1.0)    -- x = 1 or -1
go.set_scale(s)

It seems to work to flip around the origin point. Safer to keep sprite nested in another go to not mess up collision shape location.

I was able to fix this by creating a new parent go for the sprite in a collection and displacing it in the script whenever the origin flipped. Thanks for all the help!

3 Likes