Simple App Using Random Images

Hi

New to Corona and this forum so apologies in advance if this seems simple! I have no knowledge of coding whatsoever.

I am trying to create a very simple app which has 3 or 4 initial screens (e.g. about, how to, rules) with a button on each screen to move forward or backward. On the pressing of the last button e.g. on screen 4
I need the app to select and display a random image from a selection of images (min 50 max 360) and then repeat this on e.g. shake function on iphone

Does this sound easy to do and will it require a lot of code?

Thanks
Bob [import]uid: 45029 topic_id: 9338 reply_id: 309338[/import]

Assuming you have all your screens setup etc and all you need is the code to randomly create an image either on button press or shake then you could do something like this: (warning - untested and written in the browser )

[code]

local ui = require(“ui”)

local images = {}
images[1] = “image1.png”
images[2] = “image2.png”
images[3] = “image3.png”
images[4] = “image4.png”
images[5] = “image5.png”

local currentImage = nil

local destroyImage = function()

if currentImage and currentImage[“removeSelf”] then
currentImage:removeSelf()
end

currentImage = nil

end

local createRandomImage = function()

local index = math.random( 1, #images)

local path = images[index]

return display.newImage( path )

end

local onAccelerator = function( event )

if event.isShake then
destroyImage()
currentImage = createRandomImage()
end

end

local onButtonPress = function( event )

destroyImage()
currentImage = createRandomImage()

end

local button = ui.newButton
{
default = “button.png”,
over = “button-over.png”,
onRelease = onButtonPress
}
[/code] [import]uid: 5833 topic_id: 9338 reply_id: 34104[/import]

Hi Graham

Thanks for your help. I do indeed have all my screens as .png (not sure about creating buttons yet) but all artwork (other than buttons) for initial screens and image screens are complete.

I will play around with this code (as a newbie, I really do mean play around!)

What a great introduction/welcome to this forum, thanks.

Bob
[import]uid: 45029 topic_id: 9338 reply_id: 34106[/import]

Hi Bob,

You’re very welcome! This community is great and there are always people willing and able to answer questions, so once again welcome!

For buttons you will probably want to have a look at this sample app - http://developer.anscamobile.com/content/button-events - and then for screen management etc Director is pretty popular - http://developer.anscamobile.com/code/director-class-10

If you have any problems just ask :slight_smile:

Graham [import]uid: 5833 topic_id: 9338 reply_id: 34107[/import]

Hi Bob,

Welcome to Corona any question you have along the way
just post in forums and the community is great im sure
you will get a lot of help :slight_smile: but here is an advice, if you are
new to programming check out the docs they are very helpful
also go over sample codes and learn from them (they helped
me tremendously) on youtube you can find great tutorials.
All tutorials from Cheetomoskeeto helped me greatly, Also
Peach Pellens website has helpful tutorials and last but not least
the forums :slight_smile: I will post links below to help you along the path
and if you have question just post on forum and ill gladly help!

~ Best of Luck,
LeivaGames

Docs: http://developer.anscamobile.com/resources/docs/

SampleCodes: http://developer.anscamobile.com/samples

Youtube: http://www.youtube.com/user/cheetomoskeeto?feature=chclk#p/u/18/x1DcMVSXzBE

Peach Pellen: http://techority.com/

PS: Regarding changing screens try looking into Director Class
you can find it in code exchange there is also a sub forum on
Director Class itself makes things a lot easier I personally use it
and im very happy with it. [import]uid: 30314 topic_id: 9338 reply_id: 34147[/import]

Hi kurosaki88

Thanks for the welcome and the advice. I have a dilemma in that whilst I quite like the idea of learning Corona, my needs are very simple i.e. due to the nature of my business, I will only ever want/need to create games based on a particular template with slight variations. It is the content that makes the games unique, not the coding, engine, physics etc. Therefore, I have to make a decision as to whether I spend precious time learning how to code a game template myself or outsource it to a Corona ‘wizard’ who, due to its incredible simplicity, could probably create it in no time e.g. I already have an IOS and Android template which were created in a couple of hours by an IOS/Android ‘wizard’ However, I quite like the idea of creating both in the same environment because I only have a mac!

Hope this makes sense! Once again thanks for the warm welcome and should I decide to ‘learn’
Corona, I will certainly use your advice re tutorials etc.

Regards
Bob

[import]uid: 45029 topic_id: 9338 reply_id: 34225[/import]