Changing image file of a display.newImage?

Hello,

Is there a way to load a different image file for the display.newImage? I know the first time I would do something like this:

cowboy = display.newImage( "gfx/cowboy2h.png",80,280)  

But what if I want to change it to a different file and don’t want to use any of the animations or image sheets? I just want to replace it. I know I could probably do this with transition but just wanted to see if there was a way just to change the filename and have it load at that time replacing the other image.

Thanks!

Warren
[import]uid: 184193 topic_id: 37002 reply_id: 337002[/import]

Generally, my preference is to use image sheets and make the item a sprite (but not animated) and then swap the frames. But if you just want to deal with single images, this should work:

local image = display.newImage( "file1.png" )  
--later  
display.remove( image )  
image = display.newImage( "file2.png" )  

Brent [import]uid: 200026 topic_id: 37002 reply_id: 145269[/import]

Generally, my preference is to use image sheets and make the item a sprite (but not animated) and then swap the frames. But if you just want to deal with single images, this should work:

local image = display.newImage( "file1.png" )  
--later  
display.remove( image )  
image = display.newImage( "file2.png" )  

Brent [import]uid: 200026 topic_id: 37002 reply_id: 145269[/import]