Hi all,
After spending too much time on this issue, it seems clear to me that anchor points don’t work properly with imagesheets when the frame is trimmed (such as output from texture packer).
Corona does not respect the sourceX/Y/Width/Height data. Here is a simple reproduction case (complete test project included as attachment):
local SheetInfo = {} SheetInfo.sheet = { frames = { { -- redbox x=2, y=2, width=84, height=80, sourceX = 32, sourceY = 31, sourceWidth = 120, sourceHeight = 120 }, }, sheetContentWidth = 128, sheetContentHeight = 128 } SheetInfo.frameIndex = { ["redbox"] = 1, } function SheetInfo:getSheet() return self.sheet; end function SheetInfo:getFrameIndex(name) return self.frameIndex[name]; end return SheetInfo
local sheetInfo = require("testdata") local myImageSheet = graphics.newImageSheet( "testdata.png", sheetInfo:getSheet() ) local sprite = display.newSprite( myImageSheet , {frames={sheetInfo:getFrameIndex("redbox")}} ) -- We would like to scale the red box relative to its top left corner sprite.anchorX = 0 -- Set anchor sprite.anchorY = 0 sprite:scale(2,2) -- Scale it sprite.x = 0 sprite.y = 0 -- Add a circle so we can see where the display origin is local c = display.newCircle(0,0,10) c:setFillColor(0,1,0,1) -- BUG: The corner of the red box will not line up with circle center...
This bug was previously dismissed in this topic, but I think it is a serious issue, as it is core functionality.
I hope this issue can be addressed in a timely manner.
Best regards,
Christer