Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

New Sprite API - Dynamic Resolution Problem (VIDEO)?
Started by naveen_pcs Apr 25 2012 10:20 AM

6 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

naveen_pcs

[GLOBAL: userInfoPane.html]
naveen_pcs
  • Contributor

  • 262 posts
  • Corona SDK

Hey everyone,

I'm converting everything over to the new sprite API since it supports dynamic resolutions. I'm using the latest TexturePacker beta which exports a lua file that's compatible with the new API. Everything works great for regular resolution images (320x480 "base" resolution), but I'm having problems with @2x. I checked the lua file generated, and it does properly define sheetContentWidth and sheetContentHeight (256x256 in my case for standard res image sheet). I used the exact same method with TexturePacker to generate a 2x image sheet (512x512) and I simply placed it into my project folder alongside the standard res. When playing the frames, the sprite "jitters". It seems like the x and y points are getting offset by a few pixels each frame.

Here's a video of regular resolution (ignore the choppiness, just focus on the x/y pos):

http://dl.dropbox.com/u/3371101/Screen%20Recording%2039.m4v

And here's a video of the 2x file running:

http://dl.dropbox.com/u/3371101/Screen%20Recording%2040.m4v

Any idea why this is happening?

Thanks!
uid: 51654 topic_id: 25532 reply_id: 325532


[TOPIC: post.html]
#2

risingfrom

[GLOBAL: userInfoPane.html]
risingfrom
  • Observer

  • 8 posts
  • Guests

From messing around with the new api I believe when you use content scaling it does not load the data per sprite sheet. Instead it just scales the values from the base sheet loaded. If your images are not in the exact spot on all sheets your image may appear off. Try checking to see if your sprite on the high resolution sheet is in the exact location as the scaled up location data would be beaded off the original sheet. I think your image may be off a few pixels causing your jumpy image
uid: 10192 topic_id: 25532 reply_id: 103391


[TOPIC: post.html]
#3

naveen_pcs

[GLOBAL: userInfoPane.html]
naveen_pcs
  • Contributor

  • 262 posts
  • Corona SDK

Thanks, that seemed to be the issue. Here's the fix I found:

In texture packer, the "Border padding" and "Shape padding" default to "2". That's fine for regular resolution. When you want to make @2x res, you need to change both of those to "4" instead of 2. Hope this helps someone out!
uid: 51654 topic_id: 25532 reply_id: 103549


[TOPIC: post.html]
#4

nml

[GLOBAL: userInfoPane.html]
nml
  • Contributor

  • 202 posts
  • Corona SDK

i've changed border and shape padding to 4 and i still have the same problem on the HD image sheet. Should i use AutoSD or make it by hand?

[EDIT:]
Moreover, is there a way to keep my sprites in the same position in the image sheets in texture packer (in SD and HD)?
The only way i could make this work was making SD and HD image sheets separately, by hand, using a padding of "2" in SD, "4" in HD and don't allowing free sizes. Also i had to pick a basic Layout Algorithm and sort my sprites by name (ascending) in order to make sure they are located at the same exact position in both SD and HD.

This works, it is great, but i waste a lot of texture memory with unoccupied image sheet space.
uid: 105206 topic_id: 25532 reply_id: 110278


[TOPIC: post.html]
#5

Danny

[GLOBAL: userInfoPane.html]
Danny
  • Corona Geek

  • 2,597 posts
  • Corona Staff

Moved to texture packer forum, Andreas (creator of texture packer) is the man to ask
uid: 84637 topic_id: 25532 reply_id: 110301


[TOPIC: post.html]
#6

stan8

[GLOBAL: userInfoPane.html]
stan8
  • Contributor

  • 139 posts
  • Corona SDK

I have this same issue, and I think Danny should move this back to where this belonged before, this is NOT a TexturePacker issue, because no matter what settings I use, it does not work.

Also doing by hand is not working either...
This is a Corona issue, of documentation at least (explaining the exact way it extrapolate the data from x1 sheet)
uid: 142895 topic_id: 25532 reply_id: 111338


[TOPIC: post.html]
#7

danedwar

[GLOBAL: userInfoPane.html]
danedwar
  • Enthusiast

  • 47 posts
  • Corona SDK

I posted about this problem here http://developer.anscamobile.com/forum/2012/03/22/image-sheet-exporter-working-modification-corona-imagesheetlua-file

It is a problem with the dimensions of your images and how TexturePacker packs them and not Corona. If you work with the highest resolution images only you will have more success.

Let's say you are doing resolutions for iphone and iphone 4 so scale 1.0 and scale 2.0. Only work with your @2x images and make sure that they all have an even number of pixels.

Add them to TexturePacker with "border padding"=4, "shape padding" = 4, "enable auto alias" = false, "crop" = false, "scale" = 1.

Export the imagesheet.

Now set "border padding"=2, "shape padding" = 2 and "scale"= 0.5, change the name of the imagesheet that will be created and export the imagesheet.

This will work providing your @2x images have an even number of pixels. If you have odd pixels then when the sheet is packed at the lower res the pixels will not match exactly and you will either have jittering animations or the sheet will be packed in a different order and your animations will be using co-ordinates that don't work.
uid: 77943 topic_id: 25532 reply_id: 111526



[topic_controls]
[/topic_controls]