[Resolved] Dynamic Scaling and ImageSheets (Build 2012.785)

Is anyone else having issues with dynamic scaling and image sheets?
Basically:

-My 1x version looks great!

-The 2x version is distorted, such that I see the upper left quadrant of my frame/image stretched to fit the dimensions of the display object on screen.

In other words 25% of my frame has been stretched to fit the same area that should be used for the whole image!

[code]
local options =
{
– array of tables representing each frame (required)
frames =
{
– FRAME 1:
{
width = 128,
height = 128
},

– optional params; used for dynamic resolution support
sheetContentWidth = 256,
sheetContentHeight = 256

},
}

local imageSheet = graphics.newImageSheet( “thing_sheet.png”, options )
local thing = display.newImageRect( imageSheet,1,128,128)
[/code] [import]uid: 73951 topic_id: 25110 reply_id: 325110[/import]

I just tried running this;
[lua]local options =
{
– array of tables representing each frame (required)
frames =
{
– FRAME 1:
{
width = 512,
height = 256
},

– optional params; used for dynamic resolution support
sheetContentWidth = 1024,
sheetContentHeight = 1024

},
}

local imageSheet = graphics.newImageSheet( “runningcat.png”, options )
local cat = display.newImageRect( imageSheet,1,256,128)

cat.x, cat.y = 240, 160[/lua]

That uses the cat sheet from JungleScene.

It works fine on iPhone and iPad, no issues.

Can you try running that please and let me know if you have issues? If not, maybe you can go off that to remake your sprite?

OOI, how many frames are on your sheet total? [import]uid: 52491 topic_id: 25110 reply_id: 102009[/import]

Correct me if I’m wrong, but it appears you’re just using one “retina” imageSheet and scaling down for the older devices. Why else would your “cat” be half the dimensions of the defined frame?

Am I missing something? Are we not supposed to have 2 versions of an image sheet for dynamic resolution support?

I have 4 frames total.

Thanks for your prompt reply!

[import]uid: 73951 topic_id: 25110 reply_id: 102024[/import]

Hi mort,
Yes, you should have different image sheets for different resolutions. The overall “sheet size” specified by sheetContentWidth and sheetContentHeight are the dimensions for the 1x sheet. Build your other sheets in the ratios that correspond to your various resolutions.

Brent [import]uid: 9747 topic_id: 25110 reply_id: 102030[/import]

Hey mort, Brent is correct - I misunderstood originally. (My apologies, I had two threads open at once which I should know not to do by now.)

Peach :slight_smile: [import]uid: 52491 topic_id: 25110 reply_id: 102094[/import]

@ Ah, the venerable I.D./Brent. Thanks, as always. I was on the right path then. I may just have to thank you in my credits!

@ peach No worries. You’ve still been a great help.

Updated! : It turns out that trying to convert the “complex” example options table to fit the “simple” example was a bad idea. Not only did I leave out the “numFrames” parameter, but the “frames” sub-table wasn’t required either.

Fixed code (using the running cat image sheet):

local options =  
{  
 -- The params below are required  
  
 width = 256,  
 height = 128,  
 numFrames = 8,  
  
 -- The params below are optional; used for dynamic resolution support  
  
 sheetContentWidth = 512, -- width of original 1x size of entire sheet  
 sheetContentHeight = 512 -- height of original 1x size of entire sheet  
}  
  
local imageSheet = graphics.newImageSheet( "runningcat.png", options )  
local cat = display.newImageRect( imageSheet,1,256,128)  

Note: One must create a “1x” version of the running cat sheet by scaling down a duplicate copy of the original by 50%, and then leaving the existing sheet as the “retina” version and appending @2x to it. (Since we are not provided with 2 versions of the image sheet meant for dynamic resolution support.)

I apologize for any inconvenience I may have caused. @peach Good thing you asked me how many frames I was using. For some reason, I thought one wouldn’t need to specify that, given a sheet with equal frame dimensions (i.e. you can only fit 4, 128x128 frames in a sheet of 256x256). Oh well, lesson learned!
[import]uid: 73951 topic_id: 25110 reply_id: 102170[/import]

Really happy to see this resolved, thanks for posting a detailed follow up. Brent deserves a spot in many peoples credits I think :wink: [import]uid: 52491 topic_id: 25110 reply_id: 102378[/import]

Peach also deserves more credit than she gets, I would say. :slight_smile: I think the Corona community, and the people who contribute to these forums in positive ways, is yet another thing that makes this SDK better than the ones I tried in the past and abandoned. True, many products/SDKs have a “helpful community” but the Corona one just seems better somehow.

Brent Sorrentino
Ignis Design
[import]uid: 9747 topic_id: 25110 reply_id: 102475[/import]

@ID, I concur. I was just pleasantly surprised to find you helping me out once again! Sometimes I approach things from a top-down view, rather than vice versa. You know, don’t destroy the foundation if it already works. However, I had also previously set up using the complex example because of the nature of my image sheets originally.

Thank you peach for providing excellent customer service for your company.
I also appreciate the community here. Many times you find yourself lost, and quick answers to questions such as these bring your projects back to life. I’m just very concerned with quality-control, so I appreciate any help I can get going for a version 2.0 worthy release rather than a 1.0 or a what’s really a beta with a 1.0 versioning. I’ll do my best to thank as many people as I can when I get to that point. [import]uid: 73951 topic_id: 25110 reply_id: 102476[/import]

What a nice thread to be a part of :slight_smile:

@Brent - Thank you. I agree the community here is top notch and you are a big part of that, you make many, many wonderful posts.

@Mort - Appreciated. I am glad you are enjoying the community too - good luck with your 2.0 worthy release, I’m sure you can do it!

Peach :slight_smile: [import]uid: 52491 topic_id: 25110 reply_id: 102487[/import]