this is my main.lua code;
local composer = require( “composer” )
display.setStatusBar(display.HiddenStatusBar)
_G.prefLib = require “prefLib”
_G.adsLib = require “adsLib”
_G.networksLib = require “networksLib”;
local activeNetworksProviders = {
[“Android”] = {“google”, “CgkIhNyInMgZEAIQAQ”},
[“iPhone OS”] = {“gamecenter”, “CgkIhNyInMgZEAIQAQ”} --replace “gamecenter” with “none” if you don’t use any leaderboard!
};
–networksLib.init(activeNetworksProviders);
– For in game Ad’s use this table and call
local activeAdsProviders = {
[“Android”] = {“chartboost”,“admob”,“revmob”},
[“iPhone OS”] = {“chartboost”,“admob”,“revmob”},
};
adsLib.init(activeAdsProviders);
local ads = require( “ads” )
local bannerAppID = “ca-app-pub-8347067101481503/4080572917” --for your iOS banner
if ( system.getInfo( “platformName” ) == “Android” ) then
bannerAppID = “ca-app-pub-8347067101481503/2335507715” --for your Android banner
end
local adProvider = “admob”
local function adListener( event )
--(more on this later)
end
ads.show( adtype, table_of_parameters )
ads.show( “banner”, { x=0, y=0, appId=bannerAppID } )
local function adListener( event )
– The ‘event’ table includes:
– event.name: string value of “adsRequest”
– event.response: message from the ad provider about the status of this request
– event.phase: string value of “loaded”, “shown”, or “refresh”
– event.type: string value of “banner” or “interstitial”
– event.isError: boolean true or false
local msg = event.response
– Quick debug message regarding the response from the library
print( "Message from the ads library: ", msg )
if ( event.isError ) then
print( “Error, no ad received”, msg )
else
print( “Ah ha! Got one!” )
end
end
ads.init( adProvider, appID, adListener )
ads.show( “banner”, { x=0, y=0 } )
—===================sound related tasks
_G.musicChannel = 1;
audio.reserveChannels(1);
–and let’s immediately set the volume to the values saved throughout plays
local m = prefLib.getSaveValue(“musicVolume”) or .3
prefLib.setSaveValue(“musicVolume”,m,true)
audio.setVolume(m, {channel = _G.musicChannel});
for i = 2, audio.totalChannels do
local s = _G.prefLib.getSaveValue(“sfxVolume”) or 1
prefLib.setSaveValue(“sfxVolume”,s,true)
audio.setVolume(s, {channel = i});
end
–also, we’re going to use this sound everywhere, so I’ll load it here as a global variable once
_G.splashSFX = audio.loadSound(“sounds/splash.mp3”);
_G.clickSFX = audio.loadSound(“sounds/click.wav”);
_G.fireSFX = audio.loadSound(“sounds/spring.wav”);
_G.jumpSFX = audio.loadSound(“sounds/jump.wav”);
_G.rocketSFX = audio.loadSound(“sounds/rocket.wav”);
_G.fallSFX = audio.loadSound(“sounds/fall.wav”);
_G.coinSFX = audio.loadSound(“sounds/coin.mp3”);
audio.play(splashSFX, {channel = audio.findFreeChannel()});
– Later…
local img = display.newImageRect(“assets/Splash Screen1.jpg”,640,1136)
img.x = display.contentWidth/2
img.y = display.contentHeight/2
local function move()
display.remove(img);img = nil
composer.gotoScene( “homescene”,“fade”,1500 )
end
timer.performWithDelay(4000,move,1)