Image changing in buttons

Hello Corona Devs! I am newbie and I need your experienced help with buttons. I know that in Corona we can use widget.newButton with parametrs defaultFile and overFile. But what if I need more than 2 images? For example for creating soundOff and soundOn buttons or button that will change language of my game.

Hello and welcome to the community!

I usually create buttons like that out of two parts. First, I’d create the button itself (this could be that 2 image button of yours). This button itself doesn’t need to change at all. Second, I’d add an image on top of the button, e.g. sound on graphic. Then, when the button is pressed, I’d change the graphic on top of the button from sound on to sound off. Same with languages or other types of buttons.

This is just one method of doing this. How you change the graphic is also completely up to you. You could create all of the buttons and just toggle alpha values between them, or destroy existing graphic and recreate a new one, or perhaps the simplest, create a sprite and just change the frame (or fill) of the image.

@Xedur@Spyric - Is right.  This is probably best solved DIY.

However, SSKdoes have 2, 3, and 4 state image buttons which might be useful.  However, DIY is probably the best and simplest way to go.

https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/easy_interfaces/

By the way,  You have described a two-state button. Sound on, sound off, can easily be achieved with widget buttons.

Hello and welcome to the community!

I usually create buttons like that out of two parts. First, I’d create the button itself (this could be that 2 image button of yours). This button itself doesn’t need to change at all. Second, I’d add an image on top of the button, e.g. sound on graphic. Then, when the button is pressed, I’d change the graphic on top of the button from sound on to sound off. Same with languages or other types of buttons.

This is just one method of doing this. How you change the graphic is also completely up to you. You could create all of the buttons and just toggle alpha values between them, or destroy existing graphic and recreate a new one, or perhaps the simplest, create a sprite and just change the frame (or fill) of the image.

@Xedur@Spyric - Is right.  This is probably best solved DIY.

However, SSKdoes have 2, 3, and 4 state image buttons which might be useful.  However, DIY is probably the best and simplest way to go.

https://roaminggamer.github.io/RGDocs/pages/SSK2/libraries/easy_interfaces/

By the way,  You have described a two-state button. Sound on, sound off, can easily be achieved with widget buttons.