Skip to content

Instantly share code, notes, and snippets.

View nadar71's full-sized avatar
🏠
Working from home

Simone Mapelli nadar71

🏠
Working from home
View GitHub Profile
@nadar71
nadar71 / dragitemscrollview.lua
Created January 26, 2017 12:17 — forked from HoraceBury/dragitemscrollview.lua
Provides a scrollview widget which can have items dragged off it.
local widget = require("widget")
local function angleOf( ax, ay, bx, by, adjust, positive )
local angle = math.atan2( by-ay, bx-ax ) * 180/math.pi
if (adjust) then
if (type(adjust) ~= "number") then adjust = -90 end
angle = angle - adjust
if (angle < -180) then angle=angle+360 end
if (angle > 180) then angle=angle-360 end
@nadar71
nadar71 / circlelib.lua
Created January 26, 2017 12:19 — forked from HoraceBury/circlelib.lua
Create a portion of a fill or unfilled circle as a polygon and move it by it's circle-centre. Requires image: http://content.screencast.com/users/HoraceBury/folders/Default/media/18ea951e-71a1-44f4-a148-f2109a1c9059/brush2.png Download full solution: https://www.dropbox.com/s/8472upw9w2cwkwi/CircleLib.2015-12-02.001.zip?dl=0
-- circle lib
require("mathlib")
display.setDefault( "isAnchorClamped", false )
local min, max = -10000000000000, 10000000000000
local cache = {}
local circlelib = {}
@nadar71
nadar71 / FuncDelegate.lua
Created January 26, 2017 13:29 — forked from erinlin/FuncDelegate.lua
[CoronaSDK/Lua] Function Delegate
-------------------------------------
-- function delegate
-- Author: Erin Lin
-- www.erinylin.com
-- 簡易模擬 C# delegate
-- licensed under the MIT license.
-- 2015, 02
-------------------------------------
--[[
Usage1:
@nadar71
nadar71 / unzip_folder.lua
Created January 26, 2017 13:32 — forked from peter-mach/unzip_folder.lua
Unzipping the compressed folder with CoronaSDK zip plugin
local zip = require 'plugin.zip'
local zipFileName = 'zippedFolder.zip'
local function unzipListener( event )
print('unzipping complete')
end
local unzipOptions = {
zipFile = event.response.fileName,
zipBaseDir = system.TemporaryDirectory,
@nadar71
nadar71 / coronasdk-rating.lua
Created January 26, 2017 13:32 — forked from cjanis/coronasdk-rating.lua
Corona SDK Rating Prompt
-- show rating prompt
local function ratingPrompt()
local function ask()
local function answer(event)
if ("clicked" == event.action) then
if (event.index == 1) then
system.openURL("http://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=440754678")
data.rated = "yes"
writeData()
elseif (event.index == 2) then
@nadar71
nadar71 / corona-custom.lua
Created January 26, 2017 13:33 — forked from PeterDwyer/corona-custom.lua
Texturepacker template for Corona to add support for sequencedata, based on the folder structure.
-- created with TexturePacker (http://www.codeandweb.com/texturepacker)
--
-- {{smartUpdateKey}}
--
-- local sheetInfo = require("mysheet")
-- local myImageSheet = graphics.newImageSheet( "mysheet.png", sheetInfo:getSheet() )
-- local sprite = display.newSprite( myImageSheet , {frames={sheetInfo:getFrameIndex("sprite")}} )
--
{% load filter %}
@nadar71
nadar71 / line_intersection.lua
Created January 26, 2017 13:34 — forked from CoronaSDK/line_intersection.lua
Intersection of 2 lines for a Corona SDK Application
function intersection(p11,p12,p21,p22)
local Z = (p12.y-p11.y)*(p21.x-p22.x)-(p21.y-p22.y)*(p12.x-p11.x);
local Ca = (p12.y-p11.y)*(p21.x-p11.x)-(p21.y-p11.y)*(p12.x-p11.x);
local Cb = (p21.y-p11.y)*(p21.x-p22.x)-(p21.y-p22.y)*(p21.x-p11.x);
if Z == 0 and Ca == 0 and Cb == 0 then return nil end
if Z == 0 then return nil end
local targetDevice = ( system.getInfo( "model" ) )
local isTall = ( "iPhone" == system.getInfo( "model" ) ) and ( display.pixelHeight > 960 )
if isTall == false and targetDevice == "iPhone" then
application =
{
content =
{
width = 320,
height = 480,
@nadar71
nadar71 / banner.lua
Created February 4, 2017 15:53 — forked from revmob-sdk/banner.lua
RevMob Corona SDK
-- You may add this code in the main.lua file
require 'revmob'
local REVMOB_IDS = { ["Android"] = "Android App Id", ["iPhone OS"] = "IPhone OS App Id" }
RevMob.startSession(REVMOB_IDS)
local banner = RevMob.createBanner({x = display.contentWidth / 2, y = display.contentHeight - 20, width = 300, height = 40 })
-- You can also register listeners for Ad events:
revmobListener = function (event)
@nadar71
nadar71 / MapLocationActivity_deprecated.java
Created January 22, 2019 14:43
Map use location with marker activity, one with deprecated FusedLocationApi, the other updated.
public class MapLocationActivity extends AppCompatActivity
implements OnMapReadyCallback,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
LocationListener {
GoogleMap mGoogleMap;
SupportMapFragment mapFrag;
LocationRequest mLocationRequest;
GoogleApiClient mGoogleApiClient;