Hi
I am completely new to Corona (5 days) but having followed various tutorials, advice etc I have managed to get the first part of my app working using Director Class by Ricardo Rauber. This part is a simple change of scenes (images) using buttons. Thanks to all who helped.
However, (I am sure you thought there was going to be a however!) the next bit (selecting random images) is causing me problems and I have two questions.
1 Should this part be coded using Director Class (selecting random .lua files) OR not?
2 If not, how should it work?
I copied the code below from the forum and the person who posted it says it works, having pasted it into my main lua file and made the appropriate changes to the images. I can’t get this to work.
local img = { “bluebackground.png”, “redbackground.png”, “yellowbackground.png” };
local function onShake(event)
if event.isShake then
local r = math.random(1, #img);
local image = display.newImage(img[r], 0, 0);
end
return true;
end
Runtime:addEventListener(“accelerometer”, onShake);
I need to be able to select random images on shake, if anyone can provide a definitive answer/piece of code, I would be very appreciative.
Bob
[import]uid: 45029 topic_id: 9573 reply_id: 309573[/import]
