Jan 222011

I’m proud to present part 2 of Techority’s mini series, Corona For Newbies.

*UPDATED to work with new audio APIs. (February 20th, 2012)

This time we cover sound effects, background music and touch event phases (lightly, sounds and music are what it’s all about this time).

There are only 3 sections to this mini set of tutorials however as so many people requested sound, and it is entirely covered, I think you should all be quite happy.

Part 3 will be created soon so leave your suggestions; nothing too advanced though, we’re taking baby steps to help non coders ease themselves into things comfortably.

As usual, if you appreciate my efforts you can donate a buck or two using the button on the right. (Go on, who doesn’t like buying a nice girl a drink?)

Peach Pellen :)

PS – If you’re as broke as I am and have no money to donate, you can show your love by following me on Twitter and adding me on Facebook – you can also tweet about this post using the button below. Thank you!

Download Corona For Newbies Part 2
Like this post? Subscribe to the monthly newsletter!


  87 Responses to “Corona For Newbies Part 2”

  1. Hey, thanks for the great tut, also liked part 1… Hope there’s more to come! :D

  2. I think that’s a good idea for part 3, or else a separate full tutorial on the site like the kind that I used to do more often; I don’t think that a pong game would be too hard.

    I know it’s a bit painful right now, but worth learning; eventually you’ll grow to love it ;)

    I may do a review on Sprite Deck in the near future, just have to make some time :)

    Thanks again,
    Peach :)

  3. Sup peach,
    Yeah would be great if tut 3 could cover movement similar to a pong game or space invaders.
    Hey once again I think you’re giving back to the community in a large way and I am much appreciative of your efforts, I’m sure others are too ;)

    Btw I think sprite deck will help a lot in terms of saving time but the hard slog of knowing the behaviors and parameters to use is and wiring them up to the objects is kinda painful at the moment.

    Later peach, take care.

  4. Hey there Jerrym!

    I’m really glad that you appreciate my efforts and that they’ve been helpful for you :)

    I did feel overwhelmed by it and yes, I did use GS before Corona; if it weren’t for the fact that at the time GS were pushing “Direct” (I assume you’re familiar with this?) I would have likely given up and stuck with that.

    However I stuck with it and pushed my way through what tutorials were available, learning as I went – three months on, here I am.

    It will take you a week or two of looking at it daily to feel like you “get it” to some extent, but then it’s all good from there.

    I make these tutorials because I also found what was available to me a little too confusing; I thought there should be a really clear, detailed example to follow for people who had never coded before in their lives; and thus Techority was reborn as a tutorial type site to help out the community.

    If you need help or wish to request a tutorial, please let me know :)

  5. Hi peach,
    Went through your tutorials and they were fantastic, thanks for taking the time to do this. I took a look at the more complicated examples at ansca and really felt overwhelmed :(

    Did you feel this way when first starting out with corona? And were you using game salad before corona?

  6. @Jerry

    Thank you :) Appreciate that a lot.

    I learned to code by looking at the sample code on Ansca’s website – I thought it was have been easier if there was stuff like this around so I made it ^-^;

    Peach :)

  7. Thanks JC :)

    I think it’s great as many Windows users I know want to play with this stuff and can’t afford Macs – so very cool!

    Thanks for buying Happy Doodle; that game never got as much love as it deserved, I don’t think. XD

    I hope to add more tuts soon, I may or may not do a video at some point. It has been suggested, haha.

  8. hi peach,
    i am just starting out with learning corona and found you and this repository. YOU are simply magical…

    btw – where did you learn to code?

  9. p.s. is anyone else as tickled as me that corona came out for windows? now i can learn/play/program at home AND at work :-D :-D :-D

    Peach: love your site and thank you for the tuts – no slush fund in the paypal account at the moment, but did buy Happy Doodle Sushi yesterday… hope that helps and will donate someday soon… cheers!

  10. Hi all – sorry i was unclear, yes… set isiton = 1 early in the code

  11. Haha, I actually got my new bank card today! Was worried as it was late.

    Moving on, I am just a tad too swamped to look at this at the second; need sleep VERY soon – however tomorrow I will take a good look at this and figure it out for you :)

    Have a good day at work :)

  12. Thanks again (my new bank card should arrive in a week ;))

    I have two questions though.
    Why do the text appear when I press the picture the first time, and why do I have to press it two times to start the music?

    local peach = display.newImage (“peach.png”)
    peach.x = display.contentCenterX
    peach.y = display.contentCenterY

    isiton = 1

    local function toggle (event)
    if event.phase == “ended” then
    if isiton ~= 1 then
    media.playSound (“muffin.mp3″, true)
    isiton = 1
    media.pauseSound (“muffin.mp3″)
    isiton = 0
    display.newText(“Don’t pause me :(“, 75, display.contentCenterY, native.systemFont, 20)
    myText:setTextColor(255, 255, 255)

    peach:addEventListener (“touch”, toggle)

    This is fun :) To bad that my internet has (almost) stopped working for now, and even more bad that I have to go to work tomorrow (I have so many “simple” things to try out, get the text to disappear is the next step :))…

  13. It really is that easy!

    The reason that code isn’t working is because in this case your computer doesn’t know what “isiton” is.

    You need to tell your computer that before the function.

    put this;
    isiton = 1

    Somewhere above your “toggleit” function, then try ;)

  14. Hi

    I have looked at JCs toggle button, and even though i think I know what it means there are one question, “isiton”

    How do the computer know what isiton means? Or is it as simple as typing (seems to easy):
    media.playSound (“gamemusic.mp3″, true)
    isiton = 1

    If it is that easy, shouldn’t this work?

    local reset = display.newImage (“reset.png”)
    reset.x = 280
    reset.y = 450

    reset:addEventListener (“touch”, toggleit)

    local function toggleit (event)
    if event.phase == “ended” then
    if isiton ~= 1 then
    media.playSound (“gamemusic.mp3″, true)
    isiton = 1
    media.pauseSound (“gamemusic.mp3″)
    isiton = 0

  15. found it – thanks!

  16. Haha, no – http://developer.anscamobile.com/code/ghosts-vs-monsters

    That’s it there – it is a fantastic template created by Jon and Biffy Beebe :)

  17. Where is the Ghosts VS Monsters example? Is it on your site?

  18. Thanks for the input Bill :)

    My list is building and I’m attempting to organize it in a good and logical way.

    I’m thinking that a score might be the next tutorial as it seems many don’t know how to use one properly and it could be vital for the 48ers ;)


  19. Corona For Newbies – suggestions for future topics:
    - How to make a toggle button
    - How to make over & pressed states of buttons
    - How to make groups
    - How Lua tables work, and how to use them.
    - Simple collision detection
    - Basic If/then coding
    - simple animation and transitions
    - how to use sprite sheets

  20. Hello Bill!

    I just received your donation; thank you very much!

    I can certainly take a look at that, but if you are in a hurry I’d encourage you in the meantime to check out the Ghosts VS Monsters example – it contains buttons like these and might be useful to you before I get the change to write that up :)

    Hopefully I can get some new stuff up in the next day or two, it’s been mad lately!

    Peach :)

  21. Part 2 is great – Thanks! I’m already using your info in an app I’m working on!
    Can you please go over how to make a toggle button? I tried the example that JC posted above, but couldn’t get it to work.
    Also, can you cover “over” or “pressed” states on a button? You know, having another graphic show up when you hover or press the button?

  22. I am not highly knowledgeable in that area; perhaps a forum post is in order?

    If it were me I’d likely place them all individually with care; one at a time – but I agree that seems slow and possibly impractical.

    I have never made a map before; sorry I can’t give solid advice on the topic; I hate not being able to help :(

  23. “I do understand what you are trying to say; however that isn’t something that a developer does – what we…”

    So… If I was to do a blindmap of all the USA 50 states (that could be selected individually), I would actually need 50 different pictures that would be put together perfectly?
    If so, i would really want to know how to put them together.

  24. I’ve heard a lot of devs speak highly of inkscape :) I haven’t tried it but hope to soon; I’m a creature of habit, you see, and therefore only use Photoshop currently.

    Images in general it’s hard to say – it depends what size you want them to be on the screen, haha.

    For an iPhone app the background should be 320 x 480 or 480 x 320 – it depends if it’s portrait or landscape :)

    All images should be 72 DPI as well, preferably.

  25. Woot! Thanks for putting out the second part Peach. Quick question for you, how do you know what size to make background images, and images in general? I plan on using InkScape, do you recommend something else?

    Thanks again~!

  26. Yes! That’s what I like to see!

    Good job; if you continue to play around like you have there you’ll learn at a fantastic rate :D Excellent!

    Peach :)

  27. awesome! i combined the knowledge of the last two and made your pic a “toggle” button…

    (it failed without event.phase == “ended”)

    local function toggleit (event)
    if event.phase == “ended” then
    if isiton ~= 1 then
    media.playSound( “gamemusic.mp3″, true )
    isiton = 1
    media.pauseSound (“gamemusic.mp3″)
    isiton = 0

    thanks again – i can’t wait for part 3 :-D

  28. Haha I nearly mentioned that but thought it was a typo here!

    That said; background music should be (typically) as high up as possible; at least that is what I’ve been taught – however as long as it is ABOVE the function to pause it, all should be well :)

  29. I do understand what you are trying to say; however that isn’t something that a developer does – what we would do is we would use an individual image for each stage. (This isn’t a Corona limitation, it’s simply how it’s done – I’m sure there is logic to it, although I do not yet know it myself.)

    With the sound, although I can’t give you a technical answer, I can tell you that we always load background sounds at the start of the file. (Or at least as high up as possible, basically.)

    I imagine it has something to do with the function (media.pauseSound) that is tied to the reset button.

    Forgive me if that isn’t a perfect answer; this past week my sleep has been far more unusual than it normally is and it’s left me unable to think as clearly as I otherwise might!

    I’m considering releasing a simple app containing a few basic errors to teach people to trouble shoot – would this interest anyone? Please let me know.

    Peach :)

  30. Never mind my last post, even though I looked at the code many times, I totally missed that I had written “Reset.y” instead of “reset.y”…

  31. Hi again

    I have a problem…

    When I write like this, there is no sound

    local reset = display.newImage (“reset.png”)
    reset.x = 280
    Reset.y = 450

    media.playSound (“gamemusic.mp3″, true)

    But if I delete “reset” or put it after playSound, then there is sound.

    How come?

    In part 3 I would love to learn how to split a picture into several “invisible” pieces. Like if you were to take a map of USA and then being able to highlight just one state.
    Hope you understand what I’m trying to say, but maybe thats to advanced for now.

    Anyway, if you keep up like this you will definetly get a donation when my new bank card arrives.

  32. Hey Joe :)

    A lot of people ask me that.

    I learned the basics of Corona, enough to make Happy Doodle Sushi Smile, in a little over two weeks. I did that by reading code from the Code Samples and looking at the 8 minute game example on YouTube.

    I was using physics on day two and I started writing my own game at the end of day 3.

    That said, not to sound egotistical – but very few people can pick up coding that fast, especially without any prior experience. Lua is a good language but it helped that my IQ is very high and my skills focus on the logical, mathematical and my favorite – problem solving. (All useful in coding.)

    I do think reading code is a good way to learn, but it helps if you have grasped the very basics first – with that you can kind of piece together what you are seeing – like looking at a function and going “Oh OK, this does that.” type of thing.

    For me, there was no really clear, newbie friendly way to grasp the very basics – although the 8 minute game video came the closest.

    At the end of the day, the speed in which I got a good grip on the language was largely spurred on by my desire to lose my dependence on GameSalad for app making – they had just announced a plan to force all of their devs to give up their names through forced publishing and also give a cut of profits. My hatred for this plan led me to say, “You know what? Coding is scary but losing my name is worse.”

    GS has improved since then, ditching that atrocious plan – but by that stage I had already fallen in love with Corona :)

    Sorry – that was pretty long ;)

    Peach :)

  33. Peach how did you learn Lua and Corona?

  34. Haha, perhaps you should unplug your mouse ;)

    On a serious note – if anyone does have any problems with the tutorial, email me – my email address can be found on the “sponsor” and “hire me” pages and I’m always happy to help.

    Peach :)

    PS – “Ouch!”

  35. OK, i have a problem … for some reason, I can not stop playing the “ouch” audio file. How am i supposed to learn with hurdles like that???

  36. WoW!
    This feels like a second Christmas :)

    I was looking forward to getting sleep tonight but now it doesn’t look like it!

    T H A N K you Mis Australia :)

  37. Legend!

    Thanks so much for the support; I have received your donation :D

    I’m very happy that you’ve found these useful and, as I’ve said to others – if you have any requests at all please do let me know :)

    Once again, I really do appreciate the support – when people donate I feel like I’ve done something really good and useful and that makes me happy :) (Plus knowing I get some food that isn’t potato puts me in a pretty good mood too!)

    Peach :D

  38. These are great! Thank you so much. Very helpful! Donating now. :)

  39. That makes sense; I started out with GS – it is a great way to get into app development. :)

    The Sushi app isn’t bad, it took less than day to make, too! Not a fantastic game but certainly a good example of what can be achieved in almost no time at all with the right tools!

    I really must get back to making apps, I’ve only been “off” for 2 days but I feel horribly unproductive.

    Peach :)

  40. I’m still doing some stuff in GS while I learn Corona. So my first game will certainly be a GS one as I progress faster with it. But I see a lot of potential in Corona and more features too so I’ll stick with it, for sure.
    Just downloaded your Sushi app and will give it a try later after work. Nice collection of apps you did so far!
    Thumbs up!

  41. You seem like a smart guy, I’m sure you’ll pick it in no time – just stick with it :)

    It took me less than a month to release my first Corona game as a non coder – even now I’ve only had it for just over 3 months and for one of those I didn’t get to start using it, either – so in two months I know all I do now :D It’s a lovely program and language.

  42. That would be a grand day hehe. Still got to read a few times a book on LUA coding before that has a remote chance of happening for me ;)

  43. Apologies Thierry, I did understand what you meant – I’m just very tired and not the best communicator in that condition ;)

    I hope one day we BOTH have some hugely successful apps :)


  44. I feel a bit sheepish, of course you must have some cool apps! I will dig out for them. Change my previous words to “hugely successful” :))

  45. Followed!

    I have no experience with the mic so a forum topic is a good idea ;) That said, if I have time I will look into it and see what I can find out so I might be able to help :)

    I have some OK apps in the store, nothing really successful, but I also have no “normal” job and I am currently the one providing for both myself and my partner, so it all adds up. For every $5 that gets donated that’s a meal we can eat that is not made up entirely of potato! (I’m not kidding, each day I eat 4 pieces of plain toast and two potatoes worth of hot chips! – so a meal of pasta or sausages or pies is a really awesome thing to me!)

    I’ll keep an eye peeled for your forum topic, should you post it, and hope I might be of some help in that area in the near future :)

  46. Well, I hope one day you’ll have a successful app on the store to pay yourself back a bit ;) and of course that you’ll get more donation too.

    I’m a newbie in Corona so any subject you do will be good one, you’re on a good track so keep the direction!

    oh… maybe something indeed. One thing I tried to do for a couple of days was making a talking character that would repeat what comes in through the mic. I completely failed so any insight I guess could help… cheers! But I probably will post a topic for help on the forum before I loose all my hair hehe ;)


    I’m MobileArtBooks on Twitter

  47. Excellent, I was hoping I’d get to speak to you as I couldn’t find you on Twitter.

    Thank you SO much for the donation; really appreciate it :)

    People hardly ever donate and normally that doesn’t bother me; I don’t do this for money obviously – but I do really appreciate it when people show their support with donations; I don’t make much and a donation such as yours really makes a huge difference to me.

    Thanks again, honestly, it really makes me feel like I’m doing a good job.

    Let me know if you have any requests for the third part :)

    Peach :)

  48. Nice tutorials! I like them, looking forward to see and learn from the next ones. Your comments help
    Clarify how this all works. I’ll be following from now on. Great job, thanks :)

    This deserves a little more support…

  49. Hope you enjoy them – they’re very to follow :)

  50. Great Gurl!!

    I can’t wait to get Corona to start following your tutorials.

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.