Learning About Corona and Lua

Learning About Corona - ThumbnailI’m having another one of those Obi Wan Kenobi moments. Star Wars fans likely know the scene. Luke Skywalker doesn’t start out as a knight. He’s a beginner. In one of his training exercises with Obi Wan, Luke is able to deflect laser blasts with his lightsaber – without being able to use his eyes. Obi Wan congratulates Luke by saying, “That’s good, you’ve taken your first step into a larger world.” Yesterday, I took a step into a larger development world. I downloaded and installed the Corona SDK – which uses Lua. Mastering this programming language is necessary to complete my next project – The Unofficial Corona Textbook.

Learning a new programming language can seem quite intimidating to non-programmers. Even though I have experience with different types of computer languages, it was a struggle getting started with Corona. For months I didn’t even bother to download the free trial. But once I finally got started, it wasn’t so bad.

Corona is basically a happy medium between Xcode and GameSalad. Corona is easier to use than Xcode, as Objective-C is hidden. (That’s a much more complicated language than Lua.) And while Corona can do a lot more than GameSalad, it was a lot harder for me to use. Between these three SDKs you can find your comfort zone. Do you prefer power or ease, options or speed?

While I’m sharing this post with the world, it’s more of a to-do list for me. I have to get organized if I’m going to write the new textbook. To be a great teacher, you have to be a master of your trade. That means I’ll have to get a lot better at Corona before I can start writing a textbook. My plan is to convert what I learned from GameSalad and apply it in Corona. That means finding the Lua equivalent of many basic game elements…

  • Conditions – This is accomplished with Rules in GameSalad. In Lua it’s done through code – if/then/else. The problem is that I don’t fully understand how to detect conditions in Lua.
  • Spawning – How do I make an actor appear and disappear?
  • Camera – How do I make a scrolling game?
  • Game Data – How do I keep track of scoring or character information? How is this information stored to the device?
  • Particles – How do I create special effects?
  • Music – There are lots of options, but I haven’t tested it yet.
  • Controls – How does Corona handle touch events? How easy is it to control games with Corona?
  • Movement – How do I move my “Actors” in Corona?
  • Physics – GameSalad and Corona use Box2D, this shouldn’t be too difficult to understand.
  • Auto Rotation – Landscape / Portrait – I know this is possible with Corona, I just have to figure out how to do it.
  • Scenes – Is this possible with Corona? (Many of my games are a single scene anyway, but setting the scene size could be useful. What happens when objects go outside the screen?)
  • Layers – How do I organize my “Actors” in Corona?
  • Actors – What’s the terminology for “Actors” in Corona?
  • Pause – Can a game be stopped and started like with GameSalad?
  • Display Text – This is basically covered with Corona’s “Hello World” tutorial. I still need to further review this feature.
  • Timers – How do I master time in Corona?
  • Interpolate – A lot of my games use interpolation. Does Corona have something similar?
  • Constrain – This is actually part of a bigger issue. How do I make different parts of the game share data?
  • Retina Display – How does this work with Corona? What about resolution independence? Is that possible too?

That leads to the new possibilities with Corona. There are new options that I’ll have to test…

  • Arrays – Lots of GameSalad developers have been asking for this. I’ll have to see why.
  • Clock – Wow, I can actually access the system time. I should figure this out.
  • Facebook – I don’t like this website. But if my customers want to use this feature, I should probably support it. If I do support Facebook, I’m not sure which account to register for. Do I register as an individual or do I register Photics as a business? This could be dangerous, as it would likely lead to time wasted playing FarmVille. HA HA!
  • OpenFeint – I’d rather support Apple’s standard. I prefer Game Center. However, since that’s not yet available in Corona, I might want to look at this. Also, OpenFeint works on Android, so this would help with cross-platform support.
  • Android – Do I want to return to making games for Google’s operating system?
  • Sprite Sheets – Is this really useful? How’s it different from the Animate behavior?
  • Webview – I started messing around with embedded web content. I wasn’t too impressed with the results so far. “Improved WebPopup behavior” is on the Corona roadmap. Also, I’ll have to figure out how to load local html files. I was able to display Photics.com, but not a simple HTML file.
  • Universal Binaries – Wow, a single project for both iPhone and the iPad is nice idea. Yet, this seems to involve a lot of work. I’ll have to figure it out.
  • In-App purchases – That’s a good way to make additional revenue.
  • Networking – LuaSocket looks interesting.
  • Database – SQLite – Also interesting.
  • Video – I can play movies with Corona, is this worth the effort? (I’m not crazy about a popup. but it could be used for a nice intro and/or cut-scene movies. This seems like a variation of the WebPopup.)

That’s really not too much to learn. I’m actually making great progress on this project. I’m planning to convert Commove from GameSalad to Corona. That’s a pretty good learning exercise. A recent update to GameSalad broke Commove. So instead of just trying to fix it, maybe I can rebuild Commove and make it better.

2 thoughts on “Learning About Corona and Lua”

  1. I cant wait to see all your games made with Game Salad to be converted into Corona :) you are so smart!

  2. I’m making some progress in this project. I’ve been learning a lot about Corona. Some stuff is easier than I thought. Other stuff is much MUCH harder than I expected. Retina Display support is possible through Content Scaling. It’s a lot more work than with GameSalad – which is just a simple checkbox to enable Resolution Independence.

    So instead, I’ve been experimenting with the different ways to display images in Corona…

    1
    2
    3
    
    local title = display.newImageRect( "title-screen.png", display.contentWidth, display.contentHeight ) 
    title.x = display.contentWidth / 2
    title.y = display.contentHeight / 2

    By using “display.newImageRect”, I’m basically putting the image inside an imaginary box. With the scaling settings in the config file – zoomScale, zoomEven, letterbox – the display adjusts to fit the size of the screen. It’s pretty cool. It’s certainly greater control than GameSalad, but it’s a lot more work.

    This is great material for the book! Even though I feel frustrated, I’m learning a lot!

Comments are closed.