Search code examples
luacoronasdk

Is possible change the image in corona when is inicializate with Lua?


I have an image like this:

 myImage = display.display.newImage("/images/resources/res.png")
 myImage.x = 100; myImage.y = 100; myImage.property = "local";

and depending of an event, is possible change the src of "myImage" image for other without other variable?

myImage = display.newImage("/images/resources/res2.png")

Solution

  • You can't directly change the image itself unless it is an image sheet.

    But you can use image sheet and sprite sheet. You can change its image whenever you want.

    Here's an example

    http://www.coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/