Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iPhone Development with Corona SDK

iPhone Development with Corona SDK

An hour long overview of the Corona mobile development SDK I gave at 360|iDev mobile developers conference in 2010 to an audience of 50 mobile designers, developers, and other mobile professionals in San Jose, CA.

Conference: http://360idev.com/

Scott Janousek

April 16, 2010
Tweet

More Decks by Scott Janousek

Other Decks in Technology

Transcript

  1. April 13, 2010 Tuesday 4:00 pm - 5:20 pm Evan

    Kirchhoff & Scott Janousek Friday, April 16, 2010
  2. Agenda SCOTT JANOUSEK (Hooken Mobile) Overview of Corona SDK, iPhone/iPad

    speci cs, nuts & bolts EVAN KIRCHHOFF (Ansca Mobile) Game Dev & the new Corona Physics Engine Q & A The part almost everyone likes ... Friday, April 16, 2010
  3. Evan Kirchhoff Senior Software Engineer, Ansca Mobile Legacy Flash Developer

    (10+ years) Loves Physics Engines Friday, April 16, 2010
  4. Scott Janousek Boston, MA, USA 10+ year Flash Veteran 4

    years Mobile & Devices Dev Mobile & Device Platforms iPhone/iPad, Android, Symbian, Maemo, & many more I like the a lot of the ideas behind Corona Friday, April 16, 2010
  5. Scott’s Types of Projects * * Not-Corona, but no reason

    why future ports can’t happen. :) Friday, April 16, 2010
  6. Co-authored Flash Books Foundation Flash for Mobile Devices www.flashmobilebook.com AdvancED

    Flash on Devices: Mobile Development with Flash Lite and Flash 10 advancED.flashmobilebook.com Friday, April 16, 2010
  7. First impressions to Corona SDK “I can’t believe how short

    a time it took to get up to speed developing mobile apps with Corona. It’s one of the better emerging mobile development kits I’ve used recently ... pretty cool stuff.” - Scott Janousek Friday, April 16, 2010
  8. What is Corona? An SDK that allows developers to write

    mobile and device apps for various platforms, quickly, and easily. Corona is made by Ansca Mobile: www.anscamobile.com Friday, April 16, 2010
  9. Apps Corona is good at: 2-D Games Graphical-oriented Utilities Adware

    & Branded Apps Rapid Prototyping Friday, April 16, 2010
  10. Content we’ll talk about today Prototype, avoid asteroids type game

    Game with physics engine Friday, April 16, 2010
  11. Projects are kept separate folders Assets are compiled into app

    App Code starts in le “main.lua” Code Editors : Text Wrangler, BBEdit, Coda, XCode ... Corona Development Environment Friday, April 16, 2010
  12. Corona Work ow Design app in any Graphics Editor Develop

    (lua) code in any text editor Load code into Corona Simulator Test your app with Sim Compile App via XCode Deploy Friday, April 16, 2010
  13. First experiences with Lua Whoa, what language? Wow, Documentation? Awesome!

    :) LOTS of sample code? Fantastic! Also, many “syntax books” on lua Friday, April 16, 2010
  14. My First (Simple) Game Simple 2D game Only few hours

    into this project I am not done yet (prototype) I like the immediate results! Friday, April 16, 2010
  15. Lua Game Framework ui.lua - for buttons & labels sprite.lua

    - for animations Friday, April 16, 2010
  16. Deploying the Game Game still under development Not yet on

    the Apple App Store Excited about other Platforms (e.g. Android) with Corona Friday, April 16, 2010
  17. Lessons Learned along way Keep it simple Experiment with Sample

    Lua Code Visit Ansca Mobile Forum Developer Read Lua Books & Corona Docs Friday, April 16, 2010
  18. Things I like about Corona ... Toolset is easy to

    use Lua is a simple language to learn Multiple target devices API keeps expanding Physics and other Frameworks TBD The closeknit support Friday, April 16, 2010
  19. Corona 2D Physics Engine Integrates Box2D C++ libraries (as in

    Rolando & Crayon Physics) ...but with a much simpler API Not yet in beta! Friday, April 16, 2010
  20. Corona 2D Physics Engine Rigid-body physics model Continuous collision detection

    Contact, friction and restitution Joints, motors, pulleys, ragdoll, etc. Friday, April 16, 2010
  21. -0.54 1.42 2.80 -0.56 1.41 2.81 -0.58 1.39 2.83 -0.60

    1.36 2.84 -0.62 1.34 2.86 -0.64 1.31 2.87 -0.66 1.28 2.89 -0.68 1.25 2.90 -0.70 1.21 2.92 -0.72 1.17 2.93 -0.75 1.16 2.97 -0.77 1.14 3.00 -0.80 1.13 3.04 -0.83 1.11 3.07 -0.86 1.08 3.11 -0.88 1.06 3.15 -0.91 1.03 3.18 -0.93 1.04 3.17 -0.94 1.06 3.15 -0.96 1.07 3.13 -0.97 1.08 3.12 -0.99 1.09 3.10 -1.00 1.09 3.09 -1.02 1.09 3.07 -1.03 1.09 3.05 -1.05 1.09 3.04 -1.06 1.09 3.04 -1.07 1.09 3.05 -1.09 1.09 3.06 -1.10 1.09 3.06 -1.11 1.08 3.07 -1.12 1.08 3.07 -1.14 1.06 3.08 -1.15 1.05 3.09 -1.16 1.04 3.10 -1.17 1.03 3.11 -1.19 1.01 3.13 -1.20 1.00 3.14 -1.21 1.00 3.13 -1.22 1.01 3.13 -1.22 1.02 3.12 -1.23 1.02 3.12 -1.24 1.02 3.12 -1.24 1.02 3.12 -1.25 1.02 3.12 -1.25 1.02 3.12 -1.26 1.01 3.13 -1.26 1.00 3.14 -1.27 0.99 3.14 -1.27 1.00 3.14 -1.27 1.00 3.14 What does this example do? (Not that much, yet) (printf is a poor renderer) Friday, April 16, 2010
  22. What else does it need? // (OpenGL-ES setup code removed

    for clarity) // Draw "myImage.jpg" NSString *path = [[NSBundle mainBundle] pathForResource:@"myImage" ofType:@"jpg"]; NSData *texData = [[NSData alloc] initWithContentsOfFile:path]; UIImage *image = [[UIImage alloc] initWithData:texData]; if (image == nil) NSLog(@"Do real error checking here"); GLuint width = CGImageGetWidth(image.CGImage); GLuint height = CGImageGetHeight(image.CGImage); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); void *imageData = malloc( height * width * 4 ); CGContextRef context = CGBitmapContextCreate( imageData, width, height, 8, 4 * width, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big ); CGColorSpaceRelease( colorSpace ); CGRect imageRect = CGRectMake( 0, 0, width, height ); CGContextClearRect( context, imageRect ); CGContextTranslateCTM( context, 0, height - height ); CGContextDrawImage( context, imageRect, image.CGImage ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageData); CGContextRelease(context); free(imageData); [image release]; [texData release]; (etc.) Friday, April 16, 2010
  23. The equivalent Corona demo local physics = require("physics") physics.start() local

    grass = display.newImage("grass.png") grass.x = 160; grass.y = 460 physics.newSimpleBody( grass, { density=0, friction=0.5, bounce=0.5 } ) local crate = display.newImage("crate.png") crate.x = 175; crate.y = -90; physics.newSimpleBody( crate, { density=1.2, friction=0.5, bounce=0.4 } ) Friday, April 16, 2010
  24. 4. Ramp (physical) (You’d also want to add a handful

    of sprites for the castle, etc.) Friday, April 16, 2010
  25. April 13, 2010 Tuesday 4:00 pm - 5:20 pm Evan

    & Scott Friday, April 16, 2010