[Resolved] Custom widget troubles after Corona upgrade

For my first app I had redesigned some controls as newSwitch and newSlider as shown in the attached figure. After updating to the latest Corona version I have some problems with image sheet frame indexing. In other words, the frames to customize the controls are all wrong.

It seems that the problem is related to coordinates shifting of the image sheet origin.

The following code worked perfectly with version 2013.2076 but now shows error:

WARNING: Supplied frame index(58) exceed image sheet’s maximum frameIndex(4)

… and the result is disastrous.

 local options = { --array of tables representing each frame frames = { -- FRAME 1: onOffBackgroundFrame { x = 0, y = 0, width = 160, height = 24 }, -- FRAME 2: onOffHandleDefaultFrame { x = 0, y = 24, width = 28, height = 25 }, -- FRAME 3: onOffHandleOverFrame { x = 28, y = 24, width = 28, height = 25 }, -- FRAME 4: onOffOverlayFrame { x = 0, y = 49, width = 100, height = 31 }, }, --optional parameters; used for dynamic resolution support sheetContentWidth = 160, sheetContentHeight = 80 } local onOffSwitchSheet = graphics.newImageSheet( "switch/onOffSwitchSheet.png", options ) local onOffSwitch = widget.newSwitch { left = 190, top = 130, sheet = onOffSwitchSheet, onOffBackgroundFrame = 1, onOffBackgroundWidth = 160, onOffBackgroundHeight = 24, onOffHandleDefaultFrame = 2, onOffHandleOverFrame = 3, onOffOverlayFrame = 4, onOffOverlayWidth = 100, onOffOverlayHeight = 31, onOffMask = "switch/onOffMask.png", initialSwitchState = true, onPress = onOffSwitchListener, onRelease = onOffSwitchListener, }

In attach there are a screenshot of my app with the correct controls and graphic resources (spritesheet and mask file) to do some tests with code above. 

Note: these are a little different from the screen because then I did some graphical changes to have a uniform style in the game: I replaced the green and red with blue and gray and I rounded the edges of the controls.

Probably the new library Graphics 2.0 has changed something. Maybe it should be updated Widget 2.0 tutorials on GitHub …

Thanks in advance.

-j

It seems that the problem depends from loading the default theme for ios7.

The fix is to force Android theme loading before custome controls :

widget.setTheme ("widget\_theme\_android")  

Cheers.

-j

Hi jospic,

There seems to be a issue with this on the ios7 theme. I’ll look at it.

Thanks for pointing this out,

Alex

It seems that the problem depends from loading the default theme for ios7.

The fix is to force Android theme loading before custome controls :

widget.setTheme ("widget\_theme\_android")  

Cheers.

-j

Hi jospic,

There seems to be a issue with this on the ios7 theme. I’ll look at it.

Thanks for pointing this out,

Alex