How to replace a picture in the Corona SDK with another one or delete it and then install a new one? This is a general question, because I have the same trouble with the text. If the old is first equated to an empty line, and then changed to a new one, then it still remains on the screen.

    1 answer 1

    Use image:removeSelf() or display:remove(image) to remove the image and image.isVisible = false in order to hide it. Then add new instead of old:

     local imageOne = display.newImage('image1.png', 200, 200) local imageTwo = display.newImage('image2.png', 200, 200) imageTwo.isVisible = false -- скрыть вторую картинку function imageOne(click) -- по касанию меняем imageOne на imageTwo if click.phase == 'began' then imageOne:removeSelf() imageOne = nil -- приравниваем к nil, чтобы освободить память imageTwo.isVisible = true end end imageOne:addEventListener('touch', imageOne) 

    The object:removeSelf() and display:remove(object) methods work with all objects on the display, including text (you can edit it, by the way, by docking to the ".text" object, for example: myText.text = 'newText' )