All sprites from a spritesheet have dimensions of the first frame

Hi

I have just installed the last public free version of corona sdk and i have seen that if i try to use the dimensions of some sprite (width and height), all they (the sprites) have the dimensions of the first frame in the .lua doc created with TexturePacker.

http://img171.imageshack.us/img171/724/errorspriteheight.png

Bye [import]uid: 83865 topic_id: 19136 reply_id: 319136[/import]

I continue looking and i have seen something very interesting, in the same moment that i’m creating the sprite if i print the width or height corona gives to me the sizes of the first frame in .lua but later, when i do the same in the game logic, gives the correct sizes.

http://img69.imageshack.us/img69/1007/capturadepantalla201112u.png [import]uid: 83865 topic_id: 19136 reply_id: 73967[/import]

Other thing, in the line of the second reply, if I use a runtime_event or use one timer the result is not equal.

http://img842.imageshack.us/img842/2310/capturadepantalla201112j.png


Edit

I have found a solution but i really think that it is a very fat bug, anyway in that pic u can see how i do to solved it.

http://img802.imageshack.us/img802/7785/capturadepantalla201112s.png


Edit2

One best solution to this bug, thanks to other guy in my job…because here anybody say nothing :wink:
The trick is write instance.currentFrame = 1 or the frame that you want, previous to the setReference and set x/y coordinates.

bye [import]uid: 83865 topic_id: 19136 reply_id: 73974[/import]

Hello, 

I’m having this issue too…

I got tons of sprite sheets, but this one in particular is always setting currentFrame to 1

 miscSpriteSet = sprite.newSpriteMultiSet( { {sheet = spriteSheet, frames = { frameIndex["twitterIcon.png"], frameIndex["facebookIcon.png"], frameIndex["homeIcon.png"], frameIndex["miniHome.png"], frameIndex["drop.png"], frameIndex["gameOver.png"], frameIndex["timeExtended\_EN\_US.png"], frameIndex["timeExtended\_PT\_BR.png"], frameIndex["1.png"], frameIndex["2.png"], frameIndex["score\_EN\_US.png"], frameIndex["board\_EN\_US.png"], frameIndex["level\_EN\_US.png"], frameIndex["easy\_EN\_US.png"], frameIndex["normal.png"], frameIndex["hard\_EN\_US.png"], frameIndex["score\_PT\_BR.png"], frameIndex["board\_PT\_BR.png"], frameIndex["level\_PT\_BR.png"], frameIndex["easy\_PT\_BR.png"], frameIndex["hard\_PT\_BR.png"], frameIndex["heart2.png"], } }, } ) sprite.add(miscSpriteSet, "twitter", 1, 1, 500, 0) sprite.add(miscSpriteSet, "facebook", 2, 1, 500, 0) sprite.add(miscSpriteSet, "home", 3, 1, 500, 0) sprite.add(miscSpriteSet, "miniHome", 4, 1, 500, 0) sprite.add(miscSpriteSet, "drop", 5, 1, 500, 0) sprite.add(miscSpriteSet, "gameOver", 6, 1, 500, 0) sprite.add(miscSpriteSet, "timeExtended\_EN\_US", 7, 1, 500, 0) sprite.add(miscSpriteSet, "timeExtended\_PT\_BR", 8, 1, 500, 0) sprite.add(miscSpriteSet, "1", 9, 1, 500, 0) sprite.add(miscSpriteSet, "2", 10, 1, 500, 0) sprite.add(miscSpriteSet, "score\_EN\_US", 11, 1, 500, 0) sprite.add(miscSpriteSet, "board\_EN\_US", 12, 1, 500, 0) sprite.add(miscSpriteSet, "level\_EN\_US", 13, 1, 500, 0) sprite.add(miscSpriteSet, "easy\_EN\_US", 14, 1, 500, 0) sprite.add(miscSpriteSet, "normal", 15, 1, 500, 0) sprite.add(miscSpriteSet, "hard\_EN\_US", 16, 1, 500, 0) sprite.add(miscSpriteSet, "score\_PT\_BR", 17, 1, 500, 0) sprite.add(miscSpriteSet, "board\_PT\_BR", 18, 1, 500, 0) sprite.add(miscSpriteSet, "level\_PT\_BR", 19, 1, 500, 0) sprite.add(miscSpriteSet, "easy\_PT\_BR", 20, 1, 500, 0) sprite.add(miscSpriteSet, "hard\_PT\_BR", 21, 1, 500, 0) sprite.add(miscSpriteSet, "heart", 22, 1, 500, 0) ...

   local levelCaption = sprite.newSprite(miscSpriteSet)

   levelCaption:prepare(getTranslation(“score”, language, “LEVEL_TITLE”)) – this returns easy_PT_BR which is the 20th frame

   levelCaption:play()

   levelCaption.y = 0

   levelCaption.x = 0

   levelCaption:setReferencePoint(display.CenterReferencePoint)

—> print (levelCaption.currentFrame) prints 1…it should be 20

Since the currentFrame is 1 instead of 20, the contentWidth & contentHeight of the image is being set to the first image, instead to the dimensions of image 20 (50, 50 instead of 256, 256)

 

I even hard coded prepare parameter to no effect…

Any idea anyone?

Regards, Emerson

I’ve gave up last night…started change the code to make use of awesome SpriteGrabber…It is working now, but definetively it is a bug…

Hi @emersonlopes,

It appears that you’re using the deprecated “sprite” library. @killer_for_revenge, are you using it too? This library, which includes “newSpriteMultiSet”, was phased out over a year ago in favor of sprites using the “display” library (the old sprite library is provided only for legacy reasons and shouldn’t be used). Please convert your code to the current methods, and you should have no issues.

http://www.coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

Best regards,

Brent Sorrentino

Hi,

I understand that, but I’ve walked a long way with sprite library…lots of dependencies…but I’ll do, after publish my app…that’s why we do version 2 for everything :slight_smile:

Regards, Emerson

Hello, 

I’m having this issue too…

I got tons of sprite sheets, but this one in particular is always setting currentFrame to 1

 miscSpriteSet = sprite.newSpriteMultiSet( { {sheet = spriteSheet, frames = { frameIndex["twitterIcon.png"], frameIndex["facebookIcon.png"], frameIndex["homeIcon.png"], frameIndex["miniHome.png"], frameIndex["drop.png"], frameIndex["gameOver.png"], frameIndex["timeExtended\_EN\_US.png"], frameIndex["timeExtended\_PT\_BR.png"], frameIndex["1.png"], frameIndex["2.png"], frameIndex["score\_EN\_US.png"], frameIndex["board\_EN\_US.png"], frameIndex["level\_EN\_US.png"], frameIndex["easy\_EN\_US.png"], frameIndex["normal.png"], frameIndex["hard\_EN\_US.png"], frameIndex["score\_PT\_BR.png"], frameIndex["board\_PT\_BR.png"], frameIndex["level\_PT\_BR.png"], frameIndex["easy\_PT\_BR.png"], frameIndex["hard\_PT\_BR.png"], frameIndex["heart2.png"], } }, } ) sprite.add(miscSpriteSet, "twitter", 1, 1, 500, 0) sprite.add(miscSpriteSet, "facebook", 2, 1, 500, 0) sprite.add(miscSpriteSet, "home", 3, 1, 500, 0) sprite.add(miscSpriteSet, "miniHome", 4, 1, 500, 0) sprite.add(miscSpriteSet, "drop", 5, 1, 500, 0) sprite.add(miscSpriteSet, "gameOver", 6, 1, 500, 0) sprite.add(miscSpriteSet, "timeExtended\_EN\_US", 7, 1, 500, 0) sprite.add(miscSpriteSet, "timeExtended\_PT\_BR", 8, 1, 500, 0) sprite.add(miscSpriteSet, "1", 9, 1, 500, 0) sprite.add(miscSpriteSet, "2", 10, 1, 500, 0) sprite.add(miscSpriteSet, "score\_EN\_US", 11, 1, 500, 0) sprite.add(miscSpriteSet, "board\_EN\_US", 12, 1, 500, 0) sprite.add(miscSpriteSet, "level\_EN\_US", 13, 1, 500, 0) sprite.add(miscSpriteSet, "easy\_EN\_US", 14, 1, 500, 0) sprite.add(miscSpriteSet, "normal", 15, 1, 500, 0) sprite.add(miscSpriteSet, "hard\_EN\_US", 16, 1, 500, 0) sprite.add(miscSpriteSet, "score\_PT\_BR", 17, 1, 500, 0) sprite.add(miscSpriteSet, "board\_PT\_BR", 18, 1, 500, 0) sprite.add(miscSpriteSet, "level\_PT\_BR", 19, 1, 500, 0) sprite.add(miscSpriteSet, "easy\_PT\_BR", 20, 1, 500, 0) sprite.add(miscSpriteSet, "hard\_PT\_BR", 21, 1, 500, 0) sprite.add(miscSpriteSet, "heart", 22, 1, 500, 0) ...

   local levelCaption = sprite.newSprite(miscSpriteSet)

   levelCaption:prepare(getTranslation(“score”, language, “LEVEL_TITLE”)) – this returns easy_PT_BR which is the 20th frame

   levelCaption:play()

   levelCaption.y = 0

   levelCaption.x = 0

   levelCaption:setReferencePoint(display.CenterReferencePoint)

—> print (levelCaption.currentFrame) prints 1…it should be 20

Since the currentFrame is 1 instead of 20, the contentWidth & contentHeight of the image is being set to the first image, instead to the dimensions of image 20 (50, 50 instead of 256, 256)

 

I even hard coded prepare parameter to no effect…

Any idea anyone?

Regards, Emerson

I’ve gave up last night…started change the code to make use of awesome SpriteGrabber…It is working now, but definetively it is a bug…

Hi @emersonlopes,

It appears that you’re using the deprecated “sprite” library. @killer_for_revenge, are you using it too? This library, which includes “newSpriteMultiSet”, was phased out over a year ago in favor of sprites using the “display” library (the old sprite library is provided only for legacy reasons and shouldn’t be used). Please convert your code to the current methods, and you should have no issues.

http://www.coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

Best regards,

Brent Sorrentino

Hi,

I understand that, but I’ve walked a long way with sprite library…lots of dependencies…but I’ll do, after publish my app…that’s why we do version 2 for everything :slight_smile:

Regards, Emerson