11. High Performance
“Corona is a ‘godsend’. My game runs at 1 fps (frame/sec)
in Flash but runs in full 30 fps in Corona.”
– Jeff Fulton, Flash Developer
@coronalabs coronalabs.com
12. #1 on all Major Markets
iOS and Android and Amazon
@coronalabs
CONFIDENTIAL anscamobile.com
coronalabs.com
13. Developers like you
From Designers to Coders. From Indies to Studios.
#1 #1
@coronalabs coronalabs.com
14. Not just for games
HTML5 + OpenGL
Cross-device/Skinnable UI Branded Apps
@coronalabs coronalabs.com
20. Lua types
nil
boolean
• JavaScript-like syntax
number
• Functions are closures string
• Lexical scope (non-local vars) function
• Objects are tables table
userdata
@coronalabs coronalabs.com
21. Lua vs Other Languages
if
(not
carMoving)
then if
(!carMoving)
{
-‐-‐
do
something
//
do
something
elseif
(noGas)
then }
else
if
(noGas)
{
-‐-‐
do
something
else
//
do
something
else
end }
for
i
=
1,10
do for
(i=1;
i<=10;
i++)
{
print(i)
print(i)
end }
for
j
=
100,1,-‐1
do for
(j=100;
j>0;
j-‐-‐)
{
print(j)
print(j)
end }
@coronalabs coronalabs.com
22. Lua objects are Tables
array
=
{
"a",
"b",
100,
"hello"
}
dictionary
=
{
x=5,
y=7,
name="Joe"
}
t
=
{}
-‐-‐
empty
table
t[1]
=
"a"
-‐-‐
numerical
index
t["x"]
=
5
-‐-‐
key
index
t.x
=
5
-‐-‐
equivalent
property
access
t.hasProperties
=
true
t[array]
=
"Joe"
-‐-‐
any
type
can
be
a
key!!!
t["printJoe"]
=
function()
print("Joe")
end
@coronalabs coronalabs.com
23. Object methods
-‐-‐
create
empty
table
local
o
=
{}
-‐-‐
add
method
function
o:saySomething(
something
)
print(
something
)
end
-‐-‐
output
'hi'
o:saySomething(
"hi!"
)
@coronalabs coronalabs.com
24. The ':' is syntactic sugar
-‐-‐
create
empty
table
local
o
=
{}
-‐-‐
add
method
local
function
f(
self,
something
)
print(
something
)
end
o.saySomething
=
f
-‐-‐
output
'hi'
o.saySomething(
o,
"hi!"
)
@coronalabs coronalabs.com
25. Arrays are 1-based
-‐-‐
Lua:
index
begins
with
1
local
array
=
{'a','b','c'}
for
i=1,#array
do
print(
array[i]
)
end
//
Other
languages:
index
begins
with
0
array=['a','b','c'];
for
(
var
i=0;
i<arr.length;
i++)
{
log(
array[i]
)
}
@coronalabs coronalabs.com
26. Corona Enterprise
Lua and Objective-C/C++ and Java
• Integrate native libraries
• Wrap native code in your own Lua APIs
• Automate builds
@coronalabs coronalabs.com
27. API
Application Programming Interface Interaction
@coronalabs coronalabs.com
29. W e bK tabas
e
e da
S Q Li t write uage
Tons of Features File
read
/
a scr
i p t in g lan
e
g
d gr
a p hics
ll Lu lerat r
Fu - acce o mete s
ware celer o d ie
• OpenGL graphics Hard
GP S, c o mpa
ss, a
co m
c
ple x p hy
sical
,
b
etc.)
and HTTP )
• Open AL audio S impl
e
o rk ing (
T CP, F
TP,
tre amin
<html5>
g or l ocal
tion,
Netw (s , f r ic
• Box2D Physics Vi d eo playb
r
ack
oper
t ie s (mas
p
s
ulley
s, etc
.
cal p ges, dent
• Texture atlases, sprites, ... Phys
i
ts, whee
ls, hi
s
n
w i t h in
de p e
n
g pre
Jo in prite lu d i
n
• Networking An im ate d
n
s
dete
c t io n, in
o
c
rk su
ppor
t
lisio netw s an
d
• GPS, multitouch, accelerometer, ... Co
Ope
l
nFei
nt gam e
A PIs (
shap
e
ra w ing etc.)
• Native web views, textfields, ... Ve ctor
d
I (keyb
oard
,
5, sh
a 1, s h
a512
,
Nati ve U , md MP3)
• Camera, photo library, video, ... Cr yp
to (md4
d eff
e cts o
r
n l i b ra
(so un sitio
• Services: ads, analytics, IAP, ... A u d io
t io n a
n d t ra
Tw itt
n
er li
b rarie
s
A n i ma d y ha
n
• And much more! F aceb
o ok a
e d tex
n
t ure m
emor
n
pro v latio
Im
ics simu coronalabs.com y
ibrar
p hys oto l
@coronalabs
59. Pong-Lesson 2
Make paddles respond to touches
system.activate(
"multitouch"
)
local
function
startDrag(
event
)
-‐-‐
do
something
end
paddle1:addEventListener(
"touch",
startDrag
)
paddle2:addEventListener(
"touch",
startDrag
)
@coronalabs coronalabs.com
60. Pong-Lesson 2
local
function
startDrag(
event
)
local
t
=
event.target
local
phase
=
event.phase
if
"began"
==
phase
then
display.getCurrentStage():setFocus(
t,
event.id
)
t.isFocus
=
true
-‐-‐
Store
initial
position
t.x0
=
event.x
-‐
t.x
t.y0
=
event.y
-‐
t.y
...
@coronalabs coronalabs.com
61. Pong-Lesson 2
...
elseif
t.isFocus
then
if
"moved"
==
phase
then
if
(
event.y
-‐
t.y0
>
20
)
and
(
event.y
-‐
t.y0
<
_H-‐20
)
then
t.y
=
event.y
-‐
t.y0
end
elseif
"ended"==phase
or
"cancelled"==
phase
then
display.getCurrentStage():setFocus(
nil
)
t.isFocus
=
false
end
end
return
true
end
@coronalabs coronalabs.com
62. Pong-Lesson 3
Animate ball with physics
local
physics
=
require("physics")
physics.start()
physics.setGravity(
0,
0
)
@coronalabs coronalabs.com
63. Pong-Lesson 3
local
function
newBall()
ball
=
display.newImage(
"puck_yellow.png"
)
ball.x
=
_W/2
-‐-‐
center
it
ball.y
=
_H/2
ball:scale(
0.2,
0.2
)
physics.addBody(
ball,
{density=0.3,friction=0.6,radius=radius}
)
xVelocity
=
velocity
yVelocity
=
0
ball:setLinearVelocity(xVelocity,
yVelocity)
end
@coronalabs coronalabs.com
65. Pong-Lesson 5
Paddles can change ball angle. Eliminate friction.
local
function
paddleCollision(
self,
event
)
-‐-‐
do
something
end
paddle1.collision
=
paddleCollision
paddle1:addEventListener("collision",
paddle1)
paddle2.collision
=
paddleCollision
paddle2:addEventListener("collision",
paddle2)
@coronalabs coronalabs.com
66. Pong-Lesson 5
local
function
paddleCollision(
self,
event
if(
event.phase
==
"began"
)
then
local
offset
=
self.y
-‐
event.other.y
local
totalSize
=
(radius+paddleHeight)/2
local
percent
=
math.abs(offset/totalSize)
xVelocity
=
xVelocity
*
-‐1
if
offset
>
0
then
yVelocity
=
(velocity*percent)
*
-‐1
else
yVelocity
=
(velocity*percent)
end
ball:setLinearVelocity(xVelocity,yVelocity)
end
end
@coronalabs coronalabs.com
67. Pong-Lesson 6
Ball should bounce at edges of screen
local
leftWall
=
display.newRect(10,0,2,_H)
physics.addBody(
leftWall
)
leftWall.bodyType
=
"kinematic"
leftWall.myName
=
"leftWall"
local
rightWall
=
display.newRect(470,0,2,_H)
physics.addBody(
rightWall
)
rightWall.bodyType
=
"kinematic"
rightWall.myName
=
"rightWall"
@coronalabs coronalabs.com
69. Pong-Lesson 7
Maintain ball’s velocity after bouncing off top/bottom walls
local
function
onCollide(
event
)
if(
event.phase
==
"began"
)
then
yVelocity
=
yVelocity
*
-‐1
ball:setLinearVelocity(xVelocity,yVelocity)
return
true
end
end
topWall:addEventListener("collision",onCollide)
bottomWall:addEventListener("collision",onCollide)
@coronalabs coronalabs.com
70. Pong-Lesson 8
Detect when ball gets past the paddle
local
function
onSideCollision(
event
)
if
(
event.phase
==
"began"
)
then
timer.performWithDelay(
33,
removeBall
)
timer.performWithDelay(
1000,
newBall
)
end
return
true
end
leftWall:addEventListener(
"collision",
onSideCollision
)
rightWall:addEventListener(
"collision",
onSideCollision
)
@coronalabs coronalabs.com
76. Retina Imaging API
display.newImageRect(
imageName,
w,
h
)
• width/height in content units (not screen pixels)
• Best matching image file based on scale factor
• Suffixes in config.lua determine image/scale mapping
@coronalabs coronalabs.com
79. The developer community loves Corona
“In the past, we had to drop projects made in “I tried Obj-C but didn’t like the results. I found Gamesalad but
cocos2D because it was much more time wasn’t pleased with it and made the jump to Corona. I was loving it.
consuming. Corona is simple enough for an It gave me a lot more control and speed.” – Robert Nay, 14 year old
artist or designer to code a feature themselves.”
— Randy Shepherd, Cocos2d/Xbox developer “If you're serious about
developing apps and games but “For movement and performance,
“Corona performance don't want to get into Obj-C/ Appcelerator Titanium really wasn’t
“Thank you for making
is phenomenal! I love Xcode, I don't think GameSalad is an option. Corona really impressed me
Corona. I found it to be
the power and the right choice. I moved from when I saw how easy it was to get
the perfect SDK for a
flexibility. It allows me using GameSalad to Corona, graphics on to the screen and have
Flash developer like me.”
to make better games!” which is IMHO 100x better.” them look great on the device.” –
– Ferry Halim, famed
– Joe Kauffman, – Jon Beebe, ex-GameSalad user David Fox, web developer
Flash Developer and
Flash developer,
Webby Award winner
ex-GameSalad user “With Corona I felt right at home immediately, feels like JavaScript. I’m not
sleeping because the development is so addicting!” —Angelo Yazar, Unity Developer
“We were able to develop our
first application with Corona
in just a few days! Porting “We chose Corona because we’d get new
“Coming from Flash, it looked a
apps from Flash to Corona is component functions out more rapidly than
little too simplistic at the beginning,
quite easy and substantially via Cocoa Touch or Cocos2d. Supporting all
but Corona’s simplicity and ease of
lowers development costs.” of the iOS devices was a lot more seamless
use doesn’t limit what you can do.”
– Bohumil Vosicky, for us than was the case with Cocos2d.”
– Ruben Frosali, Flash Developer
educational developer — Mark Sigal, eBook publisher
“I explored many options for new iPhone “Many people think that mobile development is difficult because of the
developers and I have to say Corona just felt right. different programming languages (Objective-C, Java, etc.) For those
It was easy to pick up in a short time and powerful people, Corona is probably the best solution — it’s accessible, simple,
enough to enable really cool things to be done.” powerful, and not a barrier to creativity.” – Julian Paté, web developer
– Matt Pringle, designer for EA/3DO
@coronalabs coronalabs.com
84. Corona as a career
Over 1000+ studios in 75 countries around the world
“In what I hope is a good omen of things to come, this December
I'm on track to earn substantially more money developing Corona-
based apps for clients than I will at my (pretty well-paid) day job.
2012 may just be the year I stop working for somebody else.”
– Jason Schroedere, designer for EA/3DO
@coronalabs coronalabs.com
85. Is it fun?
“What is so great about Corona is it is so easy to just write code and get things working.
You immediately see your results on the screen.
That is what was so great about Applesoft or Logo. But they were just toy graphic languages.
Yours is first class.”
— Dave Lazarony,
Creator of ADM
(Adobe’s UI Framework)
@coronalabs coronalabs.com
86. Anyone can be #1... with Corona
@coronalabs coronalabs.com