Corona中文站

强大、易学的跨平台(iOS/Android)开发框架。QQ群1:74390406(满) 群2:221929599

导航

五分钟学会Corona(十八) - 网络和Web Services
Corona包含了最新版本(v2.02)的LuaSocket库。这些Lua模块实现的常见的网络协议,例如SMTP,HTTP和FTP。也包括一些特性支持如MIME,URL操作和LTN12。

LuaSocket是一个被预装到corona中的扩展库的集合。为了加速程序的启动,他们不会默认被自动加载。为了使用他们,你必须显式的加载每一个,以使库函数可以在你的代码中使用。为了做到这一点,你应该require他们。并且吧下面代码放在你的lua文件的顶部。

local socket = require("socket")
...
五分钟学会Corona(十七) -
Corona provides routines for calculating common message digests (hashes) and hash-based message authentication codes (HMAC).

The crypto library is an external library pre-installed into Corona apps. To speed up launch time, it is not automatically loaded by default. In order to use this library, you must explicitly load the library to make the library's functions available to your code. To do this, you should use require, i.e. placing local crypto = require("crypto") at the top of your Lua file.
...
五分钟学会Corona(十六) - Files
Applications are sandboxed meaning your files (e.g. application images, data, preferences) are stored in a location that no other application can access. Your files will reside in an app-specific directory for documents, resources, or temporary files.
...
五分钟学会Corona(十五) - Database (SQLite)
Corona includes support for SQLite databases on all platforms. This is based on the built-in sqlite support on the iPhone, and a compiled version of SQLite on Android. Note that this increases the size of the Android binary by 300K.

SQLite is available in all versions of Android, iPhone, and iPad, as well as in the Corona Simulator.
...
五分钟学会Corona(十四) - Math
This library is an interface to the standard C math library. It provides all its functions inside the table math.

math.abs (x)

Returns the absolute value of x.

math.acos (x)

Returns the arc cosine of x (in radians).

math.asin (x)

Returns the arc sine of x (in radians).
...
五分钟学会Corona(十三) - Tables and Arrays
Tables in Lua implement associative arrays. That is, they can be indexed not just with numbers, but also with strings or any other value of the language, except nil.

This library provides generic functions for table manipulation. It provides all its functions inside the table table.
...
五分钟学会Corona(十二) - 字符串处理
这个库提供了字符串处理的通用函数,例如查找和提取子字符串,以及模式匹配。当在lua中索引一个字符串时,第一个字符是从1开始的(而不象C那样从0开始)。索引号可以是附属,用来从后向前索引。例如,最后一个字符的位置就是-1,以此类推。

这个string库把所有的函数放在一个table(string)里。它允许你为字符串设置元表,__index字段指向string table。因此,你可以以面向对象的风格来使用字符串函数。例如,string.byte(s, i)也可以写成 s:byte(i)。

这个string库假定为一字节字符编码。
...
五分钟学会Corona(十一) - Event Sounds
media库提供了访问设备的多媒体特性的能力。

音频播放

media库提供了控制播放的支持:

• event sounds: 完整播放的短小的音频

• extended sounds: 可能更长,并且再播放期间可以餐厅,但是一次只能打开一个


Event Sounds

如果你有再1-3秒的短小的音频,你就应该使用event sound APIs. 下面就是一个每秒播放一声beep的节拍器的例子。

local soundID = media.newEventSound( "beep.caf" )
...
五分钟学会Corona(十) - 视频
视频回放,其实是依赖于设备指定的弹出式媒体播放器。在视频播放期间,视频播放器的界面会弹出来。

很重要的一件事是, media.playVideo是异步的。一旦代码块退出,应用程序将会被挂起,直到视频播放完成。

因此,如果媒体播放器退出时,你想要得到通知的话(例如,视频播放完毕或者用户取消了视频播放),你应该注册一个listener。

local onComplete = function(event)

print( "video session ended" )

end

media.playVideo( "Movie.m4v", true, onComplete )
...
五分钟学会Corona(九) - 音频系统
一般介绍

Corona音频系统让你可以访问高级OpenAL特性。最终它将替换Corona Event Sound系统。然而,目前它还是在计划中。请阅读这一节中对android限制,文件格式以及性能提示的重要信息。

Android: 音频文件名限制

在Android上,文件名相同但扩展名不同的文件在编译期,被映射为同一个资源名称。现在这个不优雅的错误,会携带一个连接错误:( corona.get)message。唯一的解决办法,就是修改文件名。例如,AudioPlayer范例app使用一个命名方案,简单的把扩展名合并到文件名中:
...
«123456789101112»

日历

<< 2014-10 >>

Sun

Mon

Tue

Wed

Thu

Fri

Sat

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

最近发表

Copyright 2011-2015 BuildApp.Net. All Rights Reserved.