I have created two sprite sheets using Texture Packer, one with regular resolution with this file name:
healthbar.png and healthbar@2x.png
When I publish the sheets Texture Packer generates a data format file in my case I get:
healthbar.lua and healthbar@2x.lua
When I run on an iPhone 5 all animations work fine, when I run on iPhone 7, 8 or X the graphics are not right.
When I renamed the healthbar@2x.png, the problem disappeared.
I know Lua will load the @2x on a higher resolution, my issue looks like Lua still reading the parameters from the
healthbar.png and loading the image from healthbar@2x.png.
I am handling the sprite data files correctly? How can LUA switch the data file based on the resolution? Or how can I solve this issue?
local healthbar
local healthsequenceData = {
{ name = “health1”, start = 1, count = 1, time = 250 }, { name = “health1blink”, frames = { 1,9}, time = 250, loopCount = 3 },
{ name = “health2”, start = 2, count = 1, time = 250 }, { name = “health2blink”, frames = { 2,9}, time = 250, loopCount = 3 },
{ name = “health3”, start = 3, count = 1, time = 250 }, { name = “health3blink”, frames = { 3,9}, time = 250, loopCount = 3 },
{ name = “health4”, start = 4, count = 1, time = 250 }, { name = “health4blink”, frames = { 4,9}, time = 250, loopCount = 3 },
{ name = “health5”, start = 5, count = 1, time = 250 }, { name = “health5blink”, frames = { 5,9}, time = 250, loopCount = 3 },
{ name = “health6”, start = 6, count = 1, time = 250 }, { name = “health6blink”, frames = { 6,9}, time = 150, loopCount = 3 },
{ name = “health7”, start = 7, count = 1, time = 250 }, { name = “health7blink”, frames = { 7,9}, time = 150, loopCount = 3 },
{ name = “health8”, start = 8, count = 1, time = 250 }, { name = “health8blink”, frames = { 8,9}, time = 150, loopCount = 3 },
{ name = “health9”, start = 9, count = 1, time = 250 }
}
local healthSheetInfo = require(“images.healthbar”) local healthImageSheet = graphics.newImageSheet( “images/healthbar.png”, healthSheetInfo:getSheet() ) healthbar = display.newSprite(healthImageSheet, healthsequenceData)