Very newbie question

So im working on my first project in Corona SDK and I’m pretty new to it. I was just wondering how to make widget based button thats function is to display and hide an image?
in simple way;
-there’s a button
-when you press it, some image appears on screen
-you press it once more, image disappears
Any easy code ideas? - I need really quick answer, please help  (please don’t refer me back to libraries etc.)
Thanks!

I would skip using the widget.* library to start.

You can make such an example as follows without any button libs:

local fakeButton = display.newRect( 100, 100, 100, 100 ) -- 100 x 100 square at \< 100, 100 \> local img = display.newImage( "path to your image", display.contentCenterX, display.contentCenterY ) function fakeButton.tap( self ) img.isVisible = not img.isVisible end fakeButton:addEventListener("tap")

Replace “path to your image” with the name of your image file.

That’s it.  Now you have a ‘button’ and can tap it to hide/show an image.

Once you get this working you can start embellishing.

You can learn about  widgets.* by examining the example that comes with Corona and/or by reading the API Docs, Guides, and Tutorials, the replace my simple button with a widget button.

Suggestion: If you’re going to be asking a lot of questions, you might want to shorten your name.  It is typical to respond to thread participates like this:

@name - comment 

However, your name is so long and kinda hard to type/remember … well I think you get me. :slight_smile:

I’m not dissing your selection of tag, just pointing out it will be hard to type.

In this case, I didn’t need to @name you because it was clear who I was responding to, but in long multi-user discussions, the @name practice helps us communicate clearly.

Oh, and welcome to the community.  I hope you find Corona fun and fulfilling to use.

Thanks, everything works great. If we are still here I’ll ask one more question - how integrate an audio file with that button thing we already have? I mean how to add to it sound file I have, that will play when we are pressing/un-pressing the button?

Btw. I couldn’t find nickname change option in settings, it has to be well hidden (?)

  1. It is best to create new threads for new unrelated questions.  That keeps posts bite-sized and makes them useful for future readers looking for the same kind of help, based on the title of the post.

  2. To change your name:

a. Go to top of screen.

b. click Account

c. On ‘Account Info’ line click ‘EDIT’ button.

d. Change username

e. Click ‘save’

I would skip using the widget.* library to start.

You can make such an example as follows without any button libs:

local fakeButton = display.newRect( 100, 100, 100, 100 ) -- 100 x 100 square at \< 100, 100 \> local img = display.newImage( "path to your image", display.contentCenterX, display.contentCenterY ) function fakeButton.tap( self ) img.isVisible = not img.isVisible end fakeButton:addEventListener("tap")

Replace “path to your image” with the name of your image file.

That’s it.  Now you have a ‘button’ and can tap it to hide/show an image.

Once you get this working you can start embellishing.

You can learn about  widgets.* by examining the example that comes with Corona and/or by reading the API Docs, Guides, and Tutorials, the replace my simple button with a widget button.

Suggestion: If you’re going to be asking a lot of questions, you might want to shorten your name.  It is typical to respond to thread participates like this:

@name - comment 

However, your name is so long and kinda hard to type/remember … well I think you get me. :slight_smile:

I’m not dissing your selection of tag, just pointing out it will be hard to type.

In this case, I didn’t need to @name you because it was clear who I was responding to, but in long multi-user discussions, the @name practice helps us communicate clearly.

Oh, and welcome to the community.  I hope you find Corona fun and fulfilling to use.

Thanks, everything works great. If we are still here I’ll ask one more question - how integrate an audio file with that button thing we already have? I mean how to add to it sound file I have, that will play when we are pressing/un-pressing the button?

Btw. I couldn’t find nickname change option in settings, it has to be well hidden (?)

  1. It is best to create new threads for new unrelated questions.  That keeps posts bite-sized and makes them useful for future readers looking for the same kind of help, based on the title of the post.

  2. To change your name:

a. Go to top of screen.

b. click Account

c. On ‘Account Info’ line click ‘EDIT’ button.

d. Change username

e. Click ‘save’