I’m used to programming in RealStudio. I’m new to LUA, and I’m having trouble grasping the basics/concept.
consider the following code:
local myImage
myImage = display.newImage( "red.jpg", system. ResourceDirectory, (math.random (0,320)), (math.random (0, 240)),true )
myImage = display.newImage( "blue.jpg", system. ResourceDirectory, (math.random (0,320)), (math.random (0, 240)),true )
Now, after the code has executed, everything I am used to tells me I should have one image pointed to by myImage. What I in fact have is two images.
Why doesn’t line 3 *change* myImage to be “blue.jpg”, instead it leaves “red.jpg” and creates a new instance with “blue.jpg”, thereby orphaning the original image.
So, once all 3 lines are executed, how do I reference the first image, to make it invisible for example?
How do I change the first image, rather than create a new image?
[import]uid: 74957 topic_id: 26667 reply_id: 326667[/import]