Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Help : widget.newSlider() spritesheet not working on devices
Started by nmichaud May 20 2014 09:47 AM

- - - - -
16 replies to this topic
slider newslider

Best Answer bjsorrentino , 21 May 2014 - 12:50 PM

Hi @nmichaud,

I notice you did not name the sheet file properly, which is probably why it's breaking (it can't find the sheet). You have it "sliderSheet.png" in the code and "slidersheet.png" as the file name. Files must be case-sensitive matches in every case. The Simulator can be more forgiving of this (which explains why it might work in the Simulator), but devices are not forgiving and require the case match.

 

Brent

[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

nmichaud

[GLOBAL: userInfoPane.html]
nmichaud
  • Contributor

  • 492 posts
  • Corona SDK

Hi 

 

We are creating a slider with a custom imageSheet. On the simulator (Windows and iOS) our custom slider is displayed properly. On the device on the other hand a strange blue pattern is displayed on Android and nothing on iOS.

 

Below you will find the code. Do we need to setup the theme ? If so, why ? as on the simulator it is working and based on the slider API, we provide the imageSheet.

 

Please help.

 

-- Image sheet options and declaration
        local options = {
            frames = {
                { x=0, y=0, width=16, height=35 },
                { x=40, y=0, width=16, height=35 },
                { x=80, y=0, width=16, height=35 },
                { x=124, y=0, width=16, height=35 },
                { x=168, y=0, width=35, height=35 }
            },
            sheetContentWidth = 203,
            sheetContentHeight = 35
        }
        local sliderSheet = graphics.newImageSheet( "sliderSheet.png", options )      
   
        -- Create the widget
        slider = widget.newSlider
        {
            sheet = sliderSheet,
            leftFrame = 1,
            middleFrame = 2,
            rightFrame = 3,
            fillFrame = 4,
            frameWidth = 16,
            frameHeight = 35,
            handleFrame = 5,
            handleWidth = 35,
            handleHeight = 35,
            top = screen.topBar + 4,
            left = screen.x + 10,
            orientation = "horizontal",
            width = screen.rw - 20,
            listener = sliderListener
        }
        group:insert( slider )

 

 



[TOPIC: post.html]
#2

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @nmichaud,

This sounds like you may have exceeded the device's masking limit. Are you masking the slider group and nesting it down in other masked objects like a container, tableView, or scrollView?

 

Which build # are you using?

 

Brent



[TOPIC: post.html]
#3

nmichaud

[GLOBAL: userInfoPane.html]
nmichaud
  • Contributor

  • 492 posts
  • Corona SDK

Hi @Brent, we are using build 2282 and no, the slider is not inside other nested object, nor we are using mask. We have try instantiating the slider directly in its own group without any other objects and we have the same problem.

 

On the android, it seems it is using the android theme (but its completely weird, like its trying to take our value but not our imagesheet). How can it be as we are providing our own sheet. Do we still need to create a folder theme and put our imagesheet in it ? and call settheme ?



[TOPIC: post.html]
#4

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

This may be a visual bug that will be fixed in the next batch of widget fixes, which should be coming soon. Can you post your sheet image here so I can test on my side?

 

Thanks,

Brent



[TOPIC: post.html]
#5

nmichaud

[GLOBAL: userInfoPane.html]
nmichaud
  • Contributor

  • 492 posts
  • Corona SDK

Yes, here it is :

 

slidersheet.png



[TOPIC: post.html]
#6

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @nmichaud,

I tested your slider on iOS7 using Corona build #2189, and it works fine… I see the slider and I can manipulate it as expected. I haven't tested on Android. Perhaps there's some conflict with another theme file being declared (or not declared), or perhaps are you using an older build of Corona?

 

Brent



[TOPIC: post.html]
#7

nmichaud

[GLOBAL: userInfoPane.html]
nmichaud
  • Contributor

  • 492 posts
  • Corona SDK

@Brent, we are using a more recent build #2282. Are you calling setTheme to make it work ?



[TOPIC: post.html]
#8

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

I didn't call setTheme. Also, I tested in #2303 and it looked fine.



[TOPIC: post.html]
#9

nmichaud

[GLOBAL: userInfoPane.html]
nmichaud
  • Contributor

  • 492 posts
  • Corona SDK

Well I really don't understand how it works on your side. 

 

Here is a small test app for you to test (click to download)

This demo will show you that on windows simulator it is working. If you build the app, run it on Android Samsumg S3 if will not work. Here is 2 screenshots showing it running :

 

outputslider.png



[TOPIC: post.html]
#10

nmichaud

[GLOBAL: userInfoPane.html]
nmichaud
  • Contributor

  • 492 posts
  • Corona SDK

I would really appreciate if anybody else could try the code I have posted just before this one and tell me if it works for you. We do not understand why it is not working.



[TOPIC: post.html]
#11

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

  Best Answer

Hi @nmichaud,

I notice you did not name the sheet file properly, which is probably why it's breaking (it can't find the sheet). You have it "sliderSheet.png" in the code and "slidersheet.png" as the file name. Files must be case-sensitive matches in every case. The Simulator can be more forgiving of this (which explains why it might work in the Simulator), but devices are not forgiving and require the case match.

 

Brent



[TOPIC: post.html]
#12

nmichaud

[GLOBAL: userInfoPane.html]
nmichaud
  • Contributor

  • 492 posts
  • Corona SDK

Oh no... I am so sorry. How come I did not see that. basic error, Sorry for the noise, I will go and hide in the corner for a few hours



[TOPIC: post.html]
#13

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

Brent just beat me to the line... I was coming back to post my results. Even the simulator (2014.2316) is now complaining about this : 

 

ERROR: The resource file (sliderSheet.png) could not be found at case-sensitive path (/Users/xxxxxx/Desktop/Slider Test/sliderSheet.png).
Warning: /Users/xxxxxx/Desktop/Slider Test/main.lua:21: Failed to find image 'sliderSheet.png'
 
Its great that the simulator is not as forgiving as before so you can catch these issues quickly. All the best.


[TOPIC: post.html]
#14

Gremlin Interactive

[GLOBAL: userInfoPane.html]
Gremlin Interactive
  • Contributor

  • 700 posts
  • Enterprise


Brent just beat me to the line... I was coming back to post my results. Even the simulator (2014.2316) is now complaining about this :

ERROR: The resource file (sliderSheet.png) could not be found at case-sensitive path (/Users/xxxxxx/Desktop/Slider Test/sliderSheet.png).
Warning: /Users/xxxxxx/Desktop/Slider Test/main.lua:21: Failed to find image 'sliderSheet.png'

Its great that the simulator is not as forgiving as before so you can catch these issues quickly. All the best.


If you have the "showRuntimeErrors" setting enabled on the simulator settings page... Does an error like this now halt the simulation and throw an error popup on the screen?

That would be handy.

Cheers

[TOPIC: post.html]
#15

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

There is no error popup on screen but the simulation is now halted and simulator shows you a black screen. When you look at the simulator logs you see the error I posted above. So the simulator no longer covers the capitalization mistakes you make. This is good.



[TOPIC: post.html]
#16

Gremlin Interactive

[GLOBAL: userInfoPane.html]
Gremlin Interactive
  • Contributor

  • 700 posts
  • Enterprise

There is no error popup on screen but the simulation is now halted and simulator shows you a black screen. When you look at the simulator logs you see the error I posted above. So the simulator no longer covers the capitalization mistakes you make. This is good.


Thanks for the info, that is much more helpful.

What build did this behaviour change first happen in?

[TOPIC: post.html]
#17

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

I observed this behaviour on #2316 and @nmichaud says above that he tested his code in build #2282 and obviously he wasn't presented with this error message. So in nutshell it must have been introduced somewhere between #2282 and #2316. Hope this helps.




[topic_controls]
[/topic_controls]