Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

:getSheet() makes problems on SOME android devices (galaxy ACE, FAME and Experia Tipo)
Started by Dev-Ze.rocks May 13 2014 04:30 PM

No replies to this topic
texturepacker getsheet() imagesheet android
This topic has been archived. This means that you cannot reply to this topic.
[TOPIC: post.html]


[GLOBAL: userInfoPane.html]
  • Contributor

  • 210 posts
  • Corona SDK

Good evening everybody.


As it took me long time to figure out what was the problem that my game was not running on some devices, I want to share this problem and my solution here.


With one of my updates for my game, I got a review that the game is not loading, i.e. black screen without error message.

As I changed lots of things with this update, I could not think about the new sprite sheets that I included, which I made with TexturePacker (which works great btw).

As this was the only report of that problem (and I had no chance to debug it) I disabled this model in the suported devices list in the playstore and was happy about "having this problem solved".


But then there occured more devices and I got nervous.

Finally I got one of this devices in my hands and I could debug it.

The problem is, that the getSheet() function, that comes with the .lua file that texturePacker makes, does simply not work correctly on this devices. The following code (that worked fine on all other android devices) caused the error:

local sheetInfoIngameButtons = require("ingameButtons") -- lua file that Texture packer published
local inGameButtonsSheet = graphics.newImageSheet( "images/ingameButtons.png", sheetInfoIngameButtons:getSheet())

This is the error message:


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


I tried various things, like loading the sheet options before calling newImageSheet, even with a 2500 ms delay, because I thought maybe these devices need more time to load, or what ever... but nothing helped. The only thing that worked for me and that I am now using, is loading this set of options manually, i.e. by simply copying the relevant part from the .lua file (from texturePacker) to my main.lua file...

The following is the relevant part I am talking about:

local sheetOptions =
    --array of tables representing each frame (required)
    frames =
        -- FRAME 1:
            --all parameters below are required for each frame
            x = 2,
            y = 70,
            width = 50,
            height = 50

        -- FRAME 2:
            x = 2,
            y = 242,
            width = 50,
            height = 52

        -- FRAME 3 and so on...

    --optional parameters; used for dynamic resolution support
    sheetContentWidth = 1024,
    sheetContentHeight = 1024

Then caling:

local inGameButtonsSheet = graphics.newImageSheet( "images/ingameButtons.png", sheetOptions)

works now on all devices.


I did not investigate this problem further, but maybe this description will help somebody else.


All the best,