Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

how to use spritesheet sequences with multi resolution ?
Started by edualc Jan 19 2019 10:43 PM

4 replies to this topic

Best Answer ldurniat , 20 January 2019 - 10:33 AM

Hi @edualc,

 

Maybe tutorial Dynamic Content Scaling for Corona SDK will be useful  for you.

 

Have a nice day:)

 

ldurniat

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

edualc

[GLOBAL: userInfoPane.html]
edualc
  • Enthusiast

  • 72 posts
  • Corona SDK

i,
i'm trying to set my project for multi-resolution.
i've read and understood that display.imageRect("mycar.png") will automatically pickup the right file 
if I have defined my config.lua correctly (fingers crossed I have..) and each picture has multiple resolutions as
 
mycar.png
mycar@2x.png
mycar@3x.png
 
Now i'm using spritesheet out of TexturePacker where i have
mycar01.png
mycar01@2x.png
mycar02.png
mycar02@2x.png
mycarcrash01.png
mycarcrash01@2x.png
mycarcrash02.png
mycarcrash02@2x.png
mybike01.png
mybike01@2x.png
mybike02.png
mybike02@2x.png
 
etc..
 
so far (with only mycar01.png, mycarcrash01.png, mycarcrash02.png, .. i.e. one resolution only)
it's all fine.
e.g. 
 
sheetInfomycar = require("mycarsheet")
imageSheetmycar = graphics.newImageSheet("assets/car-scene1.png", sheetInfomycar:getSheet() )


local sequenceData =
{     
{name="mycardriving", frames={1,2}, time=1000,  loopCount = 0, loopDirection = "bounce"},    
{name="mycarcrash", frames={3,4}, time=1000,  loopCount = 0, loopDirection = "bounce"},    
{name="mybikedriving", frames={5,6}, time=1000,  loopCount = 0, loopDirection = "bounce"},    
{name="mybikecrash", frames={7,8}, time=1000,  loopCount = 0, loopDirection = "bounce"}
}


  mycar = display.newSprite( imageSheetmycar,sequenceData)
  sceneGroup:insert(mycar);
  mycar.x = display.contentCenterX ; mycar.y = display.contentCenterY
  mycar:setSequence("mycardriving")
  mycar:play()
that works a treat, all good !
 
but now .. the frame index for the 'mycardriving' sequence is different depending on the resolution 
(and dont necessarily follow each other)
 
.. so do I have to say 
local sequenceData =
{     
{name="mycardriving", frames={1,2}, time=1000,  loopCount = 0, loopDirection = "bounce"},    
{name="mycardriving@2x", frames={11,12}, time=1000,  loopCount = 0, loopDirection = "bounce"},    
{name="mycarcrash", frames={3,4}, time=1000,  loopCount = 0, loopDirection = "bounce"},    
{name="mycarcrash@2x", frames={13,16}, time=1000,  loopCount = 0, loopDirection = "bounce"},    
{name="mybikedriving", frames={5,6}, time=1000,  loopCount = 0, loopDirection = "bounce"},    
{name="mybikedriving@2x", frames={14,15}, time=1000,  loopCount = 0, loopDirection = "bounce"},    
{name="mybikecrash", frames={7,8}, time=1000,  loopCount = 0, loopDirection = "bounce"}
{name="mybikecrash@2x", frames={9,10}, time=1000,  loopCount = 0, loopDirection = "bounce"}
}
and also for @3x, @4x etc.. ??
and when I code 
mycar:setSequence("mycardriving")

Corona will know to pickup  

mycar:setSequence("mycardriving@2x")
 depending on the resolution ?
  
 is this the correct ?
 
thanks@4x 
 

 



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 763 posts
  • Corona SDK

Well, that's one way to go about it, but I've never encountered this issue. The sequences should be the same across the variants unless you've renamed the images within them.

Would you upload two of those lua files outputted by TexturePacker, a default and its 2x variant, so that we can see what's wrong.



[TOPIC: post.html]
#3

schroederapps

[GLOBAL: userInfoPane.html]
schroederapps
  • Contributor

  • 466 posts
  • Corona SDK

@edualc: I think you just need to click the "force identical layout" button at the bottom of the "scaling variants" modal. Then re-pack and all of your spritesheets should work without having to switch between the different sprite sheet Lua files. 

 

See screenshot below:

Attached File  Screen Shot 2019-01-20 at 8.17.37 AM.png   169.23KB   0 downloads



[TOPIC: post.html]
#4

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 389 posts
  • Corona SDK

  Best Answer

Hi @edualc,

 

Maybe tutorial Dynamic Content Scaling for Corona SDK will be useful  for you.

 

Have a nice day:)

 

ldurniat



[TOPIC: post.html]
#5

edualc

[GLOBAL: userInfoPane.html]
edualc
  • Enthusiast

  • 72 posts
  • Corona SDK

thank you @idurniat,

that helped a lot indeed. I just wish there were an example for multisheets and sprite sequences.

But it's all good now and mycar now looks sooo sharp on my big tablet !

TexturePacker is really a very good product well worth the licence fee !

 

thanks@4x


  • Michael Flad likes this


[topic_controls]
[/topic_controls]