Hi,
I’m nearing the end of development of my game, and have run into a strange problem positioning sprites in Corona.
Here’s the TexturePacker-generated Sprite Sheet, which has “Shape Outlines” enabled and uses “Trim” to remove white space and make the sprite sheet smaller:
[lua]local SheetInfo = {}
SheetInfo.sheet =
{
frames = {
{
– BabyMushroom1_01@2x
x=428,
y=323,
width=20,
height=9,
sourceX = 44,
sourceY = 78,
sourceWidth = 100,
sourceHeight = 100
},
– Frames 2 - 18 omitted to save space
sheetContentWidth = 512,
sheetContentHeight = 512
}
SheetInfo.frameIndex =
{
[“BabyMushroom1_01@2x”] = 1,
[“BabyMushroom1_03@2x”] = 2,
[“BabyMushroom1_05@2x”] = 3,
[“BabyMushroom1_07@2x”] = 4,
[“BabyMushroom1_09@2x”] = 5,
[“BabyMushroom1_11@2x”] = 6,
[“BabyMushroom1_13@2x”] = 7,
[“BabyMushroom1_15@2x”] = 8,
[“BabyMushroom2_01@2x”] = 9,
[“BabyMushroom2_03@2x”] = 10,
[“BabyMushroom2_05@2x”] = 11,
[“BabyMushroom2_07@2x”] = 12,
[“BabyMushroom2_09@2x”] = 13,
[“BabyMushroom2_11@2x”] = 14,
[“BabyMushroom2_13@2x”] = 15,
[“BabyMushroom2_15@2x”] = 16,
[“BabyMushroom2_17@2x”] = 17,
[“BabyMushroom2_19@2x”] = 18,
}
function SheetInfo:getSheet()
return self.sheet;
end
function SheetInfo:getFrameIndex(name)
return self.frameIndex[name];
end
return SheetInfo[/lua]
Here’s my code:
[lua]display.setStatusBar(display.HiddenStatusBar)
local testSpriteSheetInfo = require(“sprites.Baby_Mushrooms-Anim”)
local testSpriteSheet = graphics.newImageSheet(“sprites/Baby_Mushrooms-Anim.png”, testSpriteSheetInfo:getSheet())
local sequenceData = {
{
name=“test”,
frames={1},
loopCount=1
},
}
local testSprite = display.newSprite(testSpriteSheet, sequenceData)
testSprite:setSequence(“test”)
testSprite:setReferencePoint(display.TopLeftReferencePoint)
testSprite.x = 0; testSprite.y = 0[/lua]
And here’s the output:
[sharedmedia=core:attachments:1368]
As you can see, the sprite is visually not at 0,0, but is a little to the right, and obviously a bit lower than it should be. I’m using build 1262, but have tried it in 2100 with V1 compatibility mode, and also 1202; all versions of Corona show it like this. Anyone have any ideas? We’re sprinting toward a deadline, and this is really slowing me down.
Thanks a lot!
- David