how to use with storyboards

Im trying to figure out how to use this in storyboard, but im getting errors with this working on my iPhone. the screen is stuck and nothing happens it doesn’t move into the next screen.

anyone can help me out???

[code]

– AD Screen inner-active.com

local storyboard = require( “storyboard” )
local scene = storyboard.newScene()

– BEGINNING OF YOUR IMPLEMENTATION

– local background
local ads = require “ads”

– Called when the scene’s view does not exist:
function scene:createScene( event )
local screenGroup = self.view

– Example for inneractive:
ads.init( “inneractive”, “APPID” )

– iPhone, iPod touch, iPad, android etc
–ads.show( “banner”, { x=0, y=0, interval=5 } )
ads.show( “fullscreen”, { x=0, y=0, interval=5 } )
–ads.show( “text”, { x=0, y=100, interval=5 } )

–[[background = display.newImageRect( “assets/graphics/title.png”, 480, 320 )
background:setReferencePoint( display.TopLeftReferencePoint )
background.x = 0; background.y = 0
screenGroup:insert( background )
–]]

print( “\nTitle: createScene event”)
end

– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view
print( “Title: enterScene event” )

local function gotoMainMenu()
storyboard.gotoScene( “mainmenu”, “fade”, 500 )
end

– To wait 5 seconds before switching scenes,
timer.performWithDelay(5000, gotoMainMenu)

local lastScene = storyboard.getPrevious()

print( “last scene was:”, lastScene ) – output: last scene name
end

– Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view
– hide all ads
ads.hide()
print( “Title: exitScene event” )
end

– Called prior to the removal of scene’s “view” (display group)
function scene:destroyScene( event )
local group = self.view
print( “((destroying Title’s view))” )
end


– END OF YOUR IMPLEMENTATION

– “createScene” event is dispatched if scene’s view does not exist
scene:addEventListener( “createScene”, scene )

– “enterScene” event is dispatched whenever scene transition has finished
scene:addEventListener( “enterScene”, scene )

– “exitScene” event is dispatched before next scene’s transition begins
scene:addEventListener( “exitScene”, scene )

– “destroyScene” event is dispatched before view is unloaded, which can be
– automatically unloaded in low memory situations, or explicitly via a call to
– storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( “destroyScene”, scene )


return scene
[/code] [import]uid: 17701 topic_id: 33167 reply_id: 333167[/import]

I would put this in your main.lua:

ads.init( “inneractive”, “APPID” )

of course changing “APPID” to your actual appID.

Then I would move the ads.show() call into enterScene and take it out of createScene. Now you’re only going to have that screen up for 5 seconds before you bounce to the next one. That’s really not enough time to show the ad (takes time to download), give the user a chance to click on it.
[import]uid: 19626 topic_id: 33167 reply_id: 131760[/import]

I would put this in your main.lua:

ads.init( “inneractive”, “APPID” )

of course changing “APPID” to your actual appID.

Then I would move the ads.show() call into enterScene and take it out of createScene. Now you’re only going to have that screen up for 5 seconds before you bounce to the next one. That’s really not enough time to show the ad (takes time to download), give the user a chance to click on it.
[import]uid: 19626 topic_id: 33167 reply_id: 131760[/import]

Rob,

thanks again for your help.

how about the

local ads = require “ads”

is that also needed to be placed in the main.lua file?

how much time should i leave the ad on for??

do they pay you for views of the ads or just the clicks???

[import]uid: 17701 topic_id: 33167 reply_id: 131892[/import]

Rob,

thanks again for your help.

how about the

local ads = require “ads”

is that also needed to be placed in the main.lua file?

how much time should i leave the ad on for??

do they pay you for views of the ads or just the clicks???

[import]uid: 17701 topic_id: 33167 reply_id: 131892[/import]

**local ads = require “ads”

is that also needed to be placed in the main.lua file?**

If you are only showing ads in that scene, you can put everything there. but its best to call the init code in main, so you will need the local ads = require “ads” in main.lua as well. Ideally you should only need to init the ads once and then call show/hide in your scenes as you need them.

how much time should i leave the ad on for??

I don’t know if inneractive has ever given any solid guidance on this but the advertisers want you to have a chance to see their ad and act upon it. I would think something on the order of 20-30 seconds would be appropriate, but you don’t want to force your players to have to wait an eternity before they can move on. Instead of moving on based on a timer, why not show the ad and give the players a “Continue” button (don’t show the button for like 5 seconds or so).

do they pay you for views of the ads or just the clicks???

A little of both. You make money on CPM (Cost per Mill) or for every 1000 ads shown you will get a few pennies. CPM rates are the lowest rates you can make. Then there is CPC or Cost Per Click. This is where you make your best money. You will get money for each click which is better than pennies for showing thousands of ads. [import]uid: 19626 topic_id: 33167 reply_id: 132128[/import]

I revised my code, now its supposed to display the ad for 8 seconds, but there are no ads being displayed

here is the revised code below

---------------------------------------------------------------------------------  
-- AD Screen inner-active.com   
---------------------------------------------------------------------------------  
local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
---------------------------------------------------------------------------------  
-- BEGINNING OF YOUR IMPLEMENTATION  
---------------------------------------------------------------------------------  
--local background  
  
-- Called when the scene's view does not exist:  
function scene:createScene( event )  
 local screenGroup = self.view  
--[[   
background = display.newImageRect( "assets/graphics/title.png", 480, 320 )  
background:setReferencePoint( display.TopLeftReferencePoint )  
background.x = 0; background.y = 0   
screenGroup:insert( background )  
--]]   
 print( "\nTitle: createScene event")  
end  
  
-- Called immediately after scene has moved onscreen:  
function scene:enterScene( event )  
 local group = self.view   
 print( "Title: enterScene event" )  
  
-- iPhone, iPod touch, iPad, android etc  
--ads.show( "banner", { x=0, y=0, interval=5 } )  
ads.show( "fullscreen", { x=0, y=0, interval=5 } )  
--ads.show( "text", { x=0, y=100, interval=5 } )   
  
 local function gotoMainMenu()  
 storyboard.gotoScene( "mainmenu", "fade", 500 )  
end  
   
-- To wait 3 seconds before switching scenes,  
timer.performWithDelay(8000, gotoMainMenu)  
  
 local lastScene = storyboard.getPrevious()  
  
 print( "last scene was:", lastScene ) -- output: last scene name  
end  
  
-- Called when scene is about to move offscreen:  
function scene:exitScene( event )  
 local group = self.view   
-- hide all ads  
ads.hide()   
 print( "Title: exitScene event" )  
end  
  
-- Called prior to the removal of scene's "view" (display group)  
function scene:destroyScene( event )  
 local group = self.view  
 print( "((destroying Title's view))" )  
end  
  
---------------------------------------------------------------------------------  
-- END OF YOUR IMPLEMENTATION  
---------------------------------------------------------------------------------  
  
-- "createScene" event is dispatched if scene's view does not exist  
scene:addEventListener( "createScene", scene )  
  
-- "enterScene" event is dispatched whenever scene transition has finished  
scene:addEventListener( "enterScene", scene )  
  
-- "exitScene" event is dispatched before next scene's transition begins  
scene:addEventListener( "exitScene", scene )  
  
-- "destroyScene" event is dispatched before view is unloaded, which can be  
-- automatically unloaded in low memory situations, or explicitly via a call to  
-- storyboard.purgeScene() or storyboard.removeScene().  
scene:addEventListener( "destroyScene", scene )  
  
---------------------------------------------------------------------------------  
  
return scene  

[import]uid: 17701 topic_id: 33167 reply_id: 132111[/import]

**local ads = require “ads”

is that also needed to be placed in the main.lua file?**

If you are only showing ads in that scene, you can put everything there. but its best to call the init code in main, so you will need the local ads = require “ads” in main.lua as well. Ideally you should only need to init the ads once and then call show/hide in your scenes as you need them.

how much time should i leave the ad on for??

I don’t know if inneractive has ever given any solid guidance on this but the advertisers want you to have a chance to see their ad and act upon it. I would think something on the order of 20-30 seconds would be appropriate, but you don’t want to force your players to have to wait an eternity before they can move on. Instead of moving on based on a timer, why not show the ad and give the players a “Continue” button (don’t show the button for like 5 seconds or so).

do they pay you for views of the ads or just the clicks???

A little of both. You make money on CPM (Cost per Mill) or for every 1000 ads shown you will get a few pennies. CPM rates are the lowest rates you can make. Then there is CPC or Cost Per Click. This is where you make your best money. You will get money for each click which is better than pennies for showing thousands of ads. [import]uid: 19626 topic_id: 33167 reply_id: 132128[/import]

I revised my code, now its supposed to display the ad for 8 seconds, but there are no ads being displayed

here is the revised code below

---------------------------------------------------------------------------------  
-- AD Screen inner-active.com   
---------------------------------------------------------------------------------  
local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
---------------------------------------------------------------------------------  
-- BEGINNING OF YOUR IMPLEMENTATION  
---------------------------------------------------------------------------------  
--local background  
  
-- Called when the scene's view does not exist:  
function scene:createScene( event )  
 local screenGroup = self.view  
--[[   
background = display.newImageRect( "assets/graphics/title.png", 480, 320 )  
background:setReferencePoint( display.TopLeftReferencePoint )  
background.x = 0; background.y = 0   
screenGroup:insert( background )  
--]]   
 print( "\nTitle: createScene event")  
end  
  
-- Called immediately after scene has moved onscreen:  
function scene:enterScene( event )  
 local group = self.view   
 print( "Title: enterScene event" )  
  
-- iPhone, iPod touch, iPad, android etc  
--ads.show( "banner", { x=0, y=0, interval=5 } )  
ads.show( "fullscreen", { x=0, y=0, interval=5 } )  
--ads.show( "text", { x=0, y=100, interval=5 } )   
  
 local function gotoMainMenu()  
 storyboard.gotoScene( "mainmenu", "fade", 500 )  
end  
   
-- To wait 3 seconds before switching scenes,  
timer.performWithDelay(8000, gotoMainMenu)  
  
 local lastScene = storyboard.getPrevious()  
  
 print( "last scene was:", lastScene ) -- output: last scene name  
end  
  
-- Called when scene is about to move offscreen:  
function scene:exitScene( event )  
 local group = self.view   
-- hide all ads  
ads.hide()   
 print( "Title: exitScene event" )  
end  
  
-- Called prior to the removal of scene's "view" (display group)  
function scene:destroyScene( event )  
 local group = self.view  
 print( "((destroying Title's view))" )  
end  
  
---------------------------------------------------------------------------------  
-- END OF YOUR IMPLEMENTATION  
---------------------------------------------------------------------------------  
  
-- "createScene" event is dispatched if scene's view does not exist  
scene:addEventListener( "createScene", scene )  
  
-- "enterScene" event is dispatched whenever scene transition has finished  
scene:addEventListener( "enterScene", scene )  
  
-- "exitScene" event is dispatched before next scene's transition begins  
scene:addEventListener( "exitScene", scene )  
  
-- "destroyScene" event is dispatched before view is unloaded, which can be  
-- automatically unloaded in low memory situations, or explicitly via a call to  
-- storyboard.purgeScene() or storyboard.removeScene().  
scene:addEventListener( "destroyScene", scene )  
  
---------------------------------------------------------------------------------  
  
return scene  

[import]uid: 17701 topic_id: 33167 reply_id: 132111[/import]

Rob,

Thanks for clearing that up for me.

That makes sense to load it in the main.lua and just show and hide it when needed.

For the ad time, i just wanted a simple add to show before the main menu. i like the idea of displaying a skip button after five seconds.

I might look into placing ads in the free version another time. i got the code working sort-of. but it displayed nothing on the screen. you did mention something about fill rates.

I assume unless i have a huge user base, the ads won’t bring in much money. [import]uid: 17701 topic_id: 33167 reply_id: 132246[/import]

Rob,

Thanks for clearing that up for me.

That makes sense to load it in the main.lua and just show and hide it when needed.

For the ad time, i just wanted a simple add to show before the main menu. i like the idea of displaying a skip button after five seconds.

I might look into placing ads in the free version another time. i got the code working sort-of. but it displayed nothing on the screen. you did mention something about fill rates.

I assume unless i have a huge user base, the ads won’t bring in much money. [import]uid: 17701 topic_id: 33167 reply_id: 132246[/import]