Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

newImageSheet and sheetContentWidth/Height error
Started by ammar71 Feb 17 2019 08:31 AM

3 replies to this topic

Best Answer ldurniat , 17 February 2019 - 11:47 AM

Is this possible upon loading or do I have to scale them as they are displayed? 

I would scale them after creation.

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ammar71

[GLOBAL: userInfoPane.html]
ammar71
  • Observer

  • 23 posts
  • Corona SDK

Hi,

 

I am experimenting with newImageSheet and I am getting the following erroe:

bad argument #2 to 'newImageSheet' (for single frame size, 'options' table must contain valid 'width' and 'height' values)

my code is as follows:

local sheet_numbers = graphics.newImageSheet("numbers.png", {width = 290,
                            height = 329, numFrames = 28,  sheetContentWidth = 109,
                          sheetContentHeight = 124})
local sequence_numbers = {
    {
        name = "allLetters",
        frames = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28 },
        time = 500,
        loopCount = 3,
        loopDirection = "forward"
    }
}
local numbers = display.newSprite( sheet_numbers, sequence_numbers )

If I remove  (sheetContentHeight = 124) the error goes away.

My understanding is that sheetContentHeight and sheetContentWidth are used to scale the sprite upon loading (which is what I am trying to achieve).

My image(attached) is a (2030  x 1316) png file. 

 

Any help with this error is highly appreciated.

Attached Files



[TOPIC: post.html]
#2

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 389 posts
  • Corona SDK

Hi @ammar71,

 

Use

sheetContentWidth = 2030, -- width of original 1x size of entire sheet 
sheetContentHeight = 1316 -- height of original 1x size of entire sheet

From documentation 

 
sheetContentWidth / sheetContentHeight (optional)

These values tell Corona the size of the original 1x image sheet. For example, if you're developing for both iPad and iPad Retina, and you're using an image sheet of 1000×1000 for the regular iPad, you should specify 1000 for both of these values and then design your Retina image sheet at 2000×2000. For more information on this topic, see the Project Configuration guide.

 

Have a nice day :)

 

ldurniat



[TOPIC: post.html]
#3

ammar71

[GLOBAL: userInfoPane.html]
ammar71
  • Observer

  • 23 posts
  • Corona SDK

Hi @ldurniat

Thanks for the answer. It seems I miss understood the docs. I was trying to change the size of sprite as it was loaded (i.e. scale it to a smaller size). Basically I use the original size in one scene but I want to make the sprite smaller in another scene. Is this possible upon loading or do I have to scale them as they are displayed? 



[TOPIC: post.html]
#4

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 389 posts
  • Corona SDK

  Best Answer

Is this possible upon loading or do I have to scale them as they are displayed? 

I would scale them after creation.


  • ammar71 likes this


[topic_controls]
[/topic_controls]