How are the variables interpreted in 2 scenarios ?

I am a bit confused reagrding local & global variables in lua, in 1st scenario i have the following piece of code

 

local myvar function dothis() myvar=display.newImage() end

in the above code dothis() is a global function , does myvar declared inside global function is local myvar or is it a global myvar?

now in 2nd scenario i have the following piece of code

--the below function is in file1.lua local myvar function dothis() myvar = display.newImage() require("file2") callfunc2() myvar:removeSelf() end ---the below function is in file2.lua local function move() --does some game logic at 30 fps end function callfunc2() --does some stuff end Runtime:addEventListener("Enterframe", move)

In scenario 2 i am calling a global function present in file2 from file1 but my doubt is when the callfunc2() is called does the execution ever proceed to myvar:removeSelf() or keeps executing the game logic in file2 with out proceeding to myvar:removeSelf()?? 

 

Scenario 1: myvar will remain local for code running in the function. scenario 2: I don’t see any reason why it would not execute all of the code in the function. Rob

Thanx rob for clarification, my game is almost completed but i am confused in deciding whether to put admob banner ads at top most screen or bottom, i can see black bars in some phones, is it possible to place banner ads on those black bars.?

Well the black bars can be coming from a couple of different sources.  It could be how you have your content area defined.  It could be how you’re backgrounds are trying to fill the screen.  If you’re on an iPhone 5 or later, you have to enable Tall Mode on iOS 7 and earlier. 

What devices are you seeing the black bars on?  Can you post your config.lua?

Rob

I am using android phone lenovo A269i , my config.lua is

 

application = { content = { width = 320, height = 480, scale = "zoomEven", fps = 30, imageSuffix = { ["@2x"] = 2, }, }, --[[-- Push notifications notification = { iphone = { types = { "badge", "sound", "alert", "newsstand" } } }, --]] }

Hmmm, zoomEven should not leave black bars.

Rob

Maybe my device is showing black bars but i don’t know about other devices, however in simulator i see no black bars for most of the devices. :huh:

Well the device is a 320x480 screen so as long as your backgrounds are at least that size you shouldn’t have black bars.  Can you grab a screens shot?  You may need to have installed the ADB.  There should be an app named “monitor” that you can use to grab a screen shot.  Your device will need to be tethered to your computer via it’s USB charging cable.

Rob

@Rob i thought to keep the black bars as is coz after admob ads are added to top of the screen it looks reasonable as they wont create unnecessary distraction to active screen during game play

Scenario 1: myvar will remain local for code running in the function. scenario 2: I don’t see any reason why it would not execute all of the code in the function. Rob

Thanx rob for clarification, my game is almost completed but i am confused in deciding whether to put admob banner ads at top most screen or bottom, i can see black bars in some phones, is it possible to place banner ads on those black bars.?

Well the black bars can be coming from a couple of different sources.  It could be how you have your content area defined.  It could be how you’re backgrounds are trying to fill the screen.  If you’re on an iPhone 5 or later, you have to enable Tall Mode on iOS 7 and earlier. 

What devices are you seeing the black bars on?  Can you post your config.lua?

Rob

I am using android phone lenovo A269i , my config.lua is

 

application = { content = { width = 320, height = 480, scale = "zoomEven", fps = 30, imageSuffix = { ["@2x"] = 2, }, }, --[[-- Push notifications notification = { iphone = { types = { "badge", "sound", "alert", "newsstand" } } }, --]] }

Hmmm, zoomEven should not leave black bars.

Rob

Maybe my device is showing black bars but i don’t know about other devices, however in simulator i see no black bars for most of the devices. :huh:

Well the device is a 320x480 screen so as long as your backgrounds are at least that size you shouldn’t have black bars.  Can you grab a screens shot?  You may need to have installed the ADB.  There should be an app named “monitor” that you can use to grab a screen shot.  Your device will need to be tethered to your computer via it’s USB charging cable.

Rob

@Rob i thought to keep the black bars as is coz after admob ads are added to top of the screen it looks reasonable as they wont create unnecessary distraction to active screen during game play