それを行うための直接的な方法はまだないと思います。しかし、画像を適切な順序で変更したい場合は、「ムービークリップ」を利用できます。
require "movieclip"
local myImage = movieclip.newAnim{ "img1.png", "img2.png" , "img3.png", "img4.png"}
myImage.x=100
myImage.y=100
local function changeImage(event)
myImage:nextFrame()
end
Runtime:addEventListener("tap", changeImage)
それ以外の場合は、古いイメージを削除して、次のように新しいイメージに置き換える必要があります。
local myImage = display.newImageRect("img1.png",150,150)
myImage.x = 100
myImage.y = 100
local function changeImage(newImage)
if(myImage~=nil)then
myImage:removeSelf()
myImage = display.newImageRect(newImage,150,150)
myImage.x = 100; myImage.y = 100
end
end
local function callMyFunction()
changeImage("hair_2.png")
end
Runtime:addEventListener("tap",callMyFunction)