iPhone Development with CORONA SDK Friday, April 16, 2010
Jan 28, 2015
iPhone Development
with CORONA SDKFriday, April 16, 2010
April 13, 2010
Tuesday 4:00 pm - 5:20 pm
Evan Kirchhoff & Scott Janousek
Friday, April 16, 2010
Intro
Friday, April 16, 2010
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 & AThe part almost everyone likes ...
Friday, April 16, 2010
Evan Kirchhoff
Senior Software Engineer, Ansca Mobile
Legacy Flash Developer (10+ years)
Loves Physics Engines
Friday, April 16, 2010
Scott JanousekBoston, MA, USA
10+ year Flash Veteran
4 years Mobile & Devices Dev
Mobile & Device PlatformsiPhone/iPad, Android, Symbian, Maemo, & many more
I like the a lot of the ideas behind Corona
Friday, April 16, 2010
Scott’s Types of Projects *
* Not-Corona, but no reason why future ports can’t happen. :)
Friday, April 16, 2010
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
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
Prototype (using Corona)
Friday, April 16, 2010
My Contact Info
SCOTT JANOUSEK
@scottjanousek
corona.scottjanousek.com
www.hookenmobile.com
Friday, April 16, 2010
Getting Started
Friday, April 16, 2010
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
Build Once, Deploy to Many
Android Apple (iPhone/iPad)
Corona SDK on a Mac
Friday, April 16, 2010
Apps Corona is good at:
2-D Games
Graphical-oriented Utilities
Adware & Branded Apps
Rapid Prototyping
Friday, April 16, 2010
Content we’ll talk about today
Prototype, avoid asteroids type game Game with physics engine
Friday, April 16, 2010
Where to download the SDK`
Friday, April 16, 2010
Registration$20 off Corona registration
COUPON CODE360idev2010
Friday, April 16, 2010
Corona installation folder
Friday, April 16, 2010
What’s in the Corona SDK
Friday, April 16, 2010
SDK Documentation
`
Friday, April 16, 2010
Sample Code
Friday, April 16, 2010
Opening Corona projects
Friday, April 16, 2010
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
SIMULATOR
Friday, April 16, 2010
SIMULATOR - iPhone
Friday, April 16, 2010
SIMULATOR - iPad
Friday, April 16, 2010
Debugger
Friday, April 16, 2010
Corona Work"owDesign 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
Lua Basics
Friday, April 16, 2010
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
Hello World with Corona
Friday, April 16, 2010
Lua Programming
Variables
Tables
Functions
Events
... more
Friday, April 16, 2010
Variables in Lua
Friday, April 16, 2010
Tables in Lua
Friday, April 16, 2010
Code Comments in Lua
Friday, April 16, 2010
Buttons in Lua
Friday, April 16, 2010
The Lua Language “Bible”
Friday, April 16, 2010
Lua Books
Friday, April 16, 2010
Code Editor to use
BBEdit
XCode
and anything else ...
Friday, April 16, 2010
Game PrototypeWalkthrough
Friday, April 16, 2010
Prototype (using Corona)
Friday, April 16, 2010
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
Designing the Game
Adobe Fireworks
(Prototyping)
Adobe Photoshop
(Production)
Friday, April 16, 2010
Developing the Game
Friday, April 16, 2010
Populating the StarField
Friday, April 16, 2010
Animating Player/Asteriods
Friday, April 16, 2010
Game Assets
Friday, April 16, 2010
Main Game Loop
Friday, April 16, 2010
Moving the Ship
Friday, April 16, 2010
Collision Detection
Friday, April 16, 2010
Lua Game Framework
ui.lua - for buttons & labels
sprite.lua - for animations
Friday, April 16, 2010
Testing the Game
Friday, April 16, 2010
File->Relaunch
You will useCommand-R
A LOT with Corona
Friday, April 16, 2010
Debugging the Game
Friday, April 16, 2010
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
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
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
Corona 2D Physics Engine
Friday, April 16, 2010
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
Corona 2D Physics Engine
Rigid-body physics model
Continuous collision detection
Contact, friction and restitution
Joints, motors, pulleys, ragdoll, etc.
Friday, April 16, 2010
Invisible Collision Geometry
Friday, April 16, 2010
Box2D: the C++ API
(...)Friday, April 16, 2010
Box2D: the C++ API (...)
Friday, April 16, 2010
-0.52 1.44 2.78-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
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
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
What does this example do?
Friday, April 16, 2010
Creating a Physics Game in Five Minutes
Friday, April 16, 2010
1. Setup
Friday, April 16, 2010
2. Background graphics
Friday, April 16, 2010
3. Ground (physical)
Friday, April 16, 2010
4. Ramp (physical)(You’d also want to add a handful of sprites for the castle, etc.)
Friday, April 16, 2010
4. Ramp (physical)
Friday, April 16, 2010
5. Place eggs (animated)
Friday, April 16, 2010
6. Score display
Friday, April 16, 2010
7. Boulder (and Camera)
Friday, April 16, 2010
8. Collision detection and scoring
Friday, April 16, 2010
9. Play game!
Friday, April 16, 2010
Wrap Up
Friday, April 16, 2010
Urls
developer.anscamobile.com
lua.org
corona.scottjanousek.com
Friday, April 16, 2010
Thanks for listening.
Friday, April 16, 2010
What are your questions?
Friday, April 16, 2010
April 13, 2010
Tuesday 4:00 pm - 5:20 pm
Evan & Scott
Friday, April 16, 2010