Log In  

Is there a way of changing the origin point of a sprite/object to be central?

in Love i would use getHeight()/2

P#35066 2017-01-06 08:59 ( Edited 2017-01-06 15:23)

I don't know exactly what you want to do, but for instance for a standard little 8 by 8 pixel sized sprite, just subtract 4.

P#35067 2017-01-06 09:25 ( Edited 2017-01-06 14:25)

there's no real sprite object, you just draw blocks from "sprite memory",
so you have to subtract your hotspot coords in the "sprite" from your destination coords, like Offler said

... or use those:

function sprc(n, x,y, w,h, fx,fy)
w,h=w or 1,h or 1
spr(n, x-w*4,y-h*4, w,h, fx,fy)
end

function ssprc(sx,sy,sw,sh, dx, dy, dw, dh, fx,fy)
dw,dh=dw or sw,dh or sh
sspr(sx,sy,sw,sh, dx-dw/2,dy-dh/2,dw,dh, fx,fy)
end
P#35069 2017-01-06 10:23 ( Edited 2017-01-06 15:30)

[Please log in to post a comment]