-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
66 lines (50 loc) · 1.86 KB
/
main.lua
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--MAIN STORYBOARD FILE
local storyboard = require "storyboard"
storyboard.purgeAll( )
ads = require( "ads" )
function adListener( event )
if ( event.isError ) then
--Failed to receive an ad
end
end
ads.init( "admob", "--publisher id goes here--", adListener )
ads.show( "banner", { x=display.screenOriginX, y=(display.contentHeight - display.screenOriginY)} )
--###########GPGS################
local gameNetwork = require( "gameNetwork" )
local playerName
local function loadLocalPlayerCallback( event )
playerName = event.data.alias
saveSettings() --save player data locally using your own "saveSettings()" function
end
local function gameNetworkLoginCallback( event )
gameNetwork.request( "loadLocalPlayer", { listener=loadLocalPlayerCallback } )
return true
end
local function gpgsInitCallback( event )
gameNetwork.request( "login", { userInitiated=true, listener=gameNetworkLoginCallback } )
end
local function gameNetworkSetup()
if ( system.getInfo("platformName") == "Android" ) then
gameNetwork.init( "google", gpgsInitCallback )
else
gameNetwork.init( "gamecenter", gameNetworkLoginCallback )
end
end
------HANDLE SYSTEM EVENTS------
local function systemEvents( event )
print("systemEvent " .. event.type)
if ( event.type == "applicationSuspend" ) then
print( "suspending..........................." )
elseif ( event.type == "applicationResume" ) then
print( "resuming............................." )
elseif ( event.type == "applicationExit" ) then
print( "exiting.............................." )
elseif ( event.type == "applicationStart" ) then
gameNetworkSetup() --login to the network here
end
return true
end
Runtime:addEventListener( "system", systemEvents )
--################GPGS##############
storyboard.gotoScene("intro")
display.setStatusBar( display.HiddenStatusBar )