Skip to content

Instantly share code, notes, and snippets.

local mySheet = graphics.newImageSheet( "runningcat.png", sheetData )
--
-- Abstract: List View sample app
--
-- Version: 2.0
--
-- Sample code is MIT licensed, see http://www.coronalabs.com/links/code/license
-- Copyright (C) 2010 Corona Labs Inc. All Rights Reserved.
--
-- Demonstrates how to create a list view using the widget's Table View Library.
-- A list view is a collection of content organized in rows that the user
local function tweetCallback( event ) -- 完成twitter動作後呼叫
if ( event.action == "cancelled" ) then -- 使用者取消
print( "User cancelled" )
else
print( "Thanks for the tweet!" ) -- 使用者分享
end
end
local options = {
message = "Hello Twitter world!", -- 預設分享文字
@fengyuanyang
fengyuanyang / main.lua
Created February 28, 2013 18:31
IOS 商店使用範例
local widget = require ("widget") -- build #1034 之前適用
local store = require("store") -- build #261 後適用
local validProducts, invalidProducts = {}, {} -- 接收有效和無效產品用
-------------------------------------------------------------------------------
-- 處理從商店取得的產品資訊,對每個產品建立按鈕
-------------------------------------------------------------------------------
function unpackValidProducts()
-- 建立購買按鈕
function newBuyButton (index)
plugins =
{
-- key is the name passed to Lua's 'require()'
["CoronaProvider.ads.admob"] =
{
-- required
publisherId = "com.coronalabs",
},
},
local ads = require "ads"
local function adListener(event)
-- 當要求到廣告時會呼叫這裡
end
-- 以下a14f8ef7162ae18為小島的APPID,請置換成你的
-- 如果沒有,也可以直接用這個測試,錢就算我的:D
--ads.init( "admob", apid, adListener )
ads.init( "admob", "a14f8ef7162ae18", adListener )
plugins =
{
-- zip plugin
["plugin.zip"] =
{
publisherId = "com.coronalabs",
},
},
local zip = require( "plugin.zip" ) -- 呼應build.settings裡的["plugin.zip"]
local function zipListener( event ) -- 解壓縮完成後呼叫此處
if ( event.isError ) then -- 若解壓有錯誤會跑至此處
print( "Unzip error" )
else
print( "event.name:" .. event.name ) -- event.name:zip
print( "event.type:" .. event.type ) -- event.type:uncompress
if ( event.response and type(event.response) == "table" ) then -- 這裡會印出所有在ZIP檔的檔名
for i = 1, #event.response do
application =
{
content =
{
graphicsCompatibility = 1, -- 加上這段
width = 320,
height = 320 * display.pixelHeight/display.pixelWidth,
scale = "letterbox",
fps = 60,