and later in the code logic I wish to change moon.png by newmoon.png. Can I use the existing moon reference and do something like:
moon:setImage("newmoon.png") --???
I read the API but didn’t find a way to set an new image to an existing display.newImageRect reference.
Thanks in advance for your help. [import]uid: 23471 topic_id: 8564 reply_id: 308564[/import]
or to clarify
[lua]local moon = display.newRect(0,0,100,100)
print(moon)
moon:removeSelf()
print(moon)
moon = display.newCircle(0,0,100)
print(moon)
local function printMoon()
print(moon) – NB, never *nil*
end
local function doRemoveAndPrint()
moon:removeSelf()
Runtime:addEventListener(“enterFrame”, printMoon)
end
moon is not nil until you set it to [lua]moon=nil[/lua]. it’s still a reference to an empty table after calling [lua]:removeSelf[/lua] [import]uid: 6645 topic_id: 8564 reply_id: 30801[/import]
In fact moon:removeSelf() is only half satisfactory because I would like to keep from my initial moon object the properties already set such as .x and .y…
When we use a display.newText object it is possible to change the text anytime with myText.text = … as shown in the example below:
Somehow the “.text” property is public for the newText object, is there a similar “.image” property available for a newImageRect object? That’s what I’m looking for really [import]uid: 23471 topic_id: 8564 reply_id: 30862[/import]
Yes a goup will certainly help me as I was looking for a form of container for my image(s).
Many thanks for your responses. [import]uid: 23471 topic_id: 8564 reply_id: 31000[/import]