0

我有这样的图像:

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

并且根据事件,是否可以将“ myImage”图像的 src 更改为其他没有其他变量的图像?

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

2 回答 2

0

除非它是图像表,否则您不能直接更改图像本身。

但是你可以使用image sheetsprite sheet。您可以随时更改其图像。

这是一个例子

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

于 2013-08-06T02:55:34.803 回答
0
chosen1pic = "selectCharacter.png"

chosen1 = display.newImage(chosen1pic)
    chosen1.x = display.contentWidth *.75
    chosen1.y = display.contentHeight *.75

choice1 = display.newImage("choice1.png")
    choice1.x = display.contentWidth /8
    choice1.y = display.contentHeight /6

local function removeImagea()
    chosen1: removeSelf()
    end

local function choicea()
    removeImagea()
    chosen2pic = "AVTR1.png"
    chosen2 = display.newImage(chosen2pic)
    chosen2.x = display.contentWidth *.2
    chosen2.y = display.contentHeight *.75
    end

choice1: addEventListener("tap", choicea)
于 2013-12-15T08:03:11.483 回答