Update image after calling display.newImage

Hi guys,

I am creating an image using ‘display.newImage’. Later on, I would like to update this image.

I tried to pass the object (created by display.newImage) and call display.newImage again. The result is 2 images are created, and it is not updating the older image.

local imgTopBanner = display.newImageRect( "assets/banner\_1.png", 390, 100 ) imgTopBanner = display.newImageRect( "assets/banner\_2.png", 390, 100 )

Please advise a better way of doing this. I hope to use it during ‘network.download()’ in the future, where an image is downloaded from the internet and automatically updates the existing picture.

thanks

You have to remove the old picture and place the new one in the same coordinates.  Or what I do is create both images at the same coordinates at the same time, then keep the second one invisible with myImg.isVisible = false.   And when the time comes I switch their visible states.

When you create newImage, image is loaded as a texture on an object and you cannot change it. You can manipulate position, width, height and other properties exposed by Corona, but you cannot change object’s texture. You have to create new object with desired image as separate one and use tricks written in post above.

Thanks guys!

You have to remove the old picture and place the new one in the same coordinates.  Or what I do is create both images at the same coordinates at the same time, then keep the second one invisible with myImg.isVisible = false.   And when the time comes I switch their visible states.

When you create newImage, image is loaded as a texture on an object and you cannot change it. You can manipulate position, width, height and other properties exposed by Corona, but you cannot change object’s texture. You have to create new object with desired image as separate one and use tricks written in post above.

Thanks guys!