1. Trang chủ
  2. » Công Nghệ Thông Tin

ansca-corona-102.pdf

23 622 3
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Corona 102 Functions & EventListeners
Trường học Ansca Mobile
Thể loại Tài liệu
Năm xuất bản 2025
Định dạng
Số trang 23
Dung lượng 492,5 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Corona

Trang 1

www.anscamobile.com

Trang 2

What’s Corona

A simple, yet powerful framework allowing rapid

mobile cross platform application development.

Trang 3

Corona 102

Functions &

EventListeners

Trang 4

Corona framework based on Lua

Trang 5

Corona Lua resources

http://ww.lua.org http://www.lua.org/lua-l.html http://developer.anscamobile.com/

http://en.wikipedia.org/wiki/Lua_

Trang 6

Corona Without functions

local text = display.newText("hello",100,200,"Helvetica",24);

textObj:setTextColor(r,g,b);

Disadvantages:

When program begins to get too big, difficult to manage code

reusing code becomes hard to break apart

debugging becomes a nightmare

no sense of where program starts

Trang 7

Corona With Functions:

local function STextColor(textObj, r,g,b)

textObj:setTextColor(r,g,b);

end

local function main()

local text = display.newText("hello",100,200,"Helvetica",24);

STxtColor(text,255,0,0);

end

main()

Advantages:

easier to manage code

easier to re-use code on other programs as well

easier to debug since you can narrow down where error occurs

a sense of where program starts

Trang 8

Corona Functions:

Trang 9

Corona Function Definitions:

( ) indicates variable args and { } places them in a table where

they processed in standard way

Trang 10

Corona More function definitions:

Trang 11

Corona Calling functions:

foo(args)

simple call returning zero or more values.

t.f(args)

calling function store in field f of table t

local function f(mode, value)

Trang 12

Corona EventListeners:

Corona’s event listeners are part of the

Corona framework and not part of the Lua

programming language.

http://developer.anscamobile.com/content/events-and-listeners

Trang 13

Corona EventListeners:

and program scope to register for specific

events to respond to.

http://developer.anscamobile.com/content/events-and-listeners

Trang 15

Corona EventListeners:

There are two types of event listeners

‘Runtime’ dispatched by the system

‘Display-object’ self-explanatory.

http://developer.anscamobile.com/content/events-and-listeners

Trang 16

Corona Runtime Event Listeners:

local function onEnterFrame(event)

print (event.name)

end

Runtime:addEventListener(“enterFrame”,onEnterFrame)

http://developer.anscamobile.com/content/events-and-listeners

Trang 17

Corona Display Object Event Listeners:

local button = display.newImage(“button.png”,15,25);

local function button:touch(event)

print (event.name)

end

button:addEventListener(“touch”,button)

http://developer.anscamobile.com/content/events-and-listeners

Trang 18

local listener = function(event)

print( event.name, event.time )

end

Runtime:addEventListener("enterFrame", listener)

Trang 21

cicaza @ anscamobile dot com

Trang 22

Corona SDK

Code Less Play More.

Ngày đăng: 01/09/2012, 08:48

TỪ KHÓA LIÊN QUAN

w