Dynamic Scaling Spritesheet issue

Hello,

I’m sure this problem has a simple solution, but I’m having trouble figuring it out.  I’ve googled around and haven’t found too much.

Simple setup - trying to get multiple display resolutions supported - standard, @2x, @4x.

When I run it, the images I have get substituted properly - only problem is that the spritesheet options don’t get changed - so the @2x image is substituted in on iphone 4s, but since the spritesheet options don’t get changed, it shows just the top left quarter of the sprite.

It would seem as though there would be an automatic way to fix this - but I can’t find it.

Further strangeness - I set “width” in config.lua to be 320, and run it on iphone and display.pixelWidth / display.actualContentWidth comes out to .66?!?

This doesn’t make sense to me, so I would appreciate any help with getting this sorted out.

THANKS!!

Hi @hdtruelson,

Without seeing your actual code, I’m guessing that you forgot to include the “sheetContentWidth” and “sheetContentHeight” parameters when setting up your image sheet parameters. So, Corona doesn’t know that you want to use dynamic image selection on them. Please see the following docs which describe this in more detail:

http://docs.coronalabs.com/api/library/graphics/newImageSheet.html

On your second issue, please post the content of your config.lua and maybe we can spot something amiss.

Thanks,

Brent

Hello Brent,

Thank you Thank you!  That got it working with “sheetContentWidth” and height.

as to the second, here is my config.lua file:

local aspectRatio = display.pixelHeight / display.pixelWidth; print( 'size = ' &nbsp;.. display.pixelWidth / display.actualContentWidth ) application = { &nbsp; &nbsp;content = { &nbsp; &nbsp; &nbsp; width = 320 --aspectRatio \> 1.5 and 320 or math.ceil( 480 / aspectRatio ), &nbsp; &nbsp; &nbsp; height = 480 --aspectRatio \< 1.5 and 480 or math.ceil( 320 \* aspectRatio ), &nbsp; &nbsp; &nbsp; scale = "letterBox", &nbsp; &nbsp; &nbsp; fps = 30, &nbsp; &nbsp; &nbsp; xAlign = left, &nbsp; &nbsp; &nbsp; imageSuffix = { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;["@2x"] = 1.5, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;["@4x"] = 3.0, &nbsp; &nbsp; &nbsp; }, &nbsp; &nbsp;}, }

I have this code in my main.lua and it outputs .666667 when tested on regular iphone simulator

local resolutionFactor = display.pixelWidth / display.actualContentWidth; print('the factor is' .. resolutionFactor)

However this line at the top of the config.lua file prints 1.529e-006

print( 'size = ' &nbsp;.. display.pixelWidth / display.actualContentWidth )

I don’t really know what to make of it.  Do you?

Hi @hdtruelson,

This is probably because you’re making that call before you set up the content area. Try moving those lines down below the “application” table block.

Best regards,

Brent

Hi @hdtruelson,

Without seeing your actual code, I’m guessing that you forgot to include the “sheetContentWidth” and “sheetContentHeight” parameters when setting up your image sheet parameters. So, Corona doesn’t know that you want to use dynamic image selection on them. Please see the following docs which describe this in more detail:

http://docs.coronalabs.com/api/library/graphics/newImageSheet.html

On your second issue, please post the content of your config.lua and maybe we can spot something amiss.

Thanks,

Brent

Hello Brent,

Thank you Thank you!  That got it working with “sheetContentWidth” and height.

as to the second, here is my config.lua file:

local aspectRatio = display.pixelHeight / display.pixelWidth; print( 'size = ' &nbsp;.. display.pixelWidth / display.actualContentWidth ) application = { &nbsp; &nbsp;content = { &nbsp; &nbsp; &nbsp; width = 320 --aspectRatio \> 1.5 and 320 or math.ceil( 480 / aspectRatio ), &nbsp; &nbsp; &nbsp; height = 480 --aspectRatio \< 1.5 and 480 or math.ceil( 320 \* aspectRatio ), &nbsp; &nbsp; &nbsp; scale = "letterBox", &nbsp; &nbsp; &nbsp; fps = 30, &nbsp; &nbsp; &nbsp; xAlign = left, &nbsp; &nbsp; &nbsp; imageSuffix = { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;["@2x"] = 1.5, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;["@4x"] = 3.0, &nbsp; &nbsp; &nbsp; }, &nbsp; &nbsp;}, }

I have this code in my main.lua and it outputs .666667 when tested on regular iphone simulator

local resolutionFactor = display.pixelWidth / display.actualContentWidth; print('the factor is' .. resolutionFactor)

However this line at the top of the config.lua file prints 1.529e-006

print( 'size = ' &nbsp;.. display.pixelWidth / display.actualContentWidth )

I don’t really know what to make of it.  Do you?

Hi @hdtruelson,

This is probably because you’re making that call before you set up the content area. Try moving those lines down below the “application” table block.

Best regards,

Brent