I’m currently having issues with my code. I’m a total newbie to this stuff so this may be an easy fix but I can’t figure it out. I’m trying to have an random image load when the user shakes the iphone. I’ve managed to get the images to load up but I want the last image loaded to be replaced with the new image. It just keeps stacking the images on top of each other and I can’t seem to remove the previous image on the shake function. Here’s my code:
local shake = { "1.png", "2.png", "3.png", "4.png" }
function shake:accelerometer(e) if (e.isShake == true) then
octohedron.isVisible = true
transition.from(octohedron, {alpha = 0})
local r = math.random ( 1, 4 )
local imageResult = display.newImage( shake [r], 110, 176)
transition.from(imageResult, {alpha = 0})
end
end
Runtime:addEventListener("accelerometer", shake)
Any help would be awesome! [import]uid: 79620 topic_id: 15800 reply_id: 315800[/import]
[import]uid: 3826 topic_id: 15800 reply_id: 58361[/import]