Hello,
I am trying to get different classes working. But i run into a problem
As a test I tried to put a background in another class and then load it into my level1.lua.
Loading the background does seem to work, but extra information like position does not seem to work and I get the following error when running the game:
background 1: table: 0x5f3d80
Runtime error
...pplications/CoronaSDK/Games/\*/Background.lua:4: attempt to index global 'bkg' (a nil value)
stack traceback:
[C]: ?
...pplications/CoronaSDK/Games/\*/Background.lua:4: in function 'new'
/Applications/CoronaSDK/Games/\*/level1.lua:34: in function
?: in function 'dispatchEvent'
?: in function 'gotoScene'
/Applications/CoronaSDK/Games/\*/menu.lua:22: in function 'onRelease'
?: in function <?:90>
?: in function <?:215>
heres the code from my background class:
Background = {}
function Background:new(startX, startY)
local background = display.newImage( "Graphics/Game/World1/background.jpg")
bkg:setReferencePoint(display.TopLeftReferencePoint)
bkg.x = startX
bkg.y = startY
return background
end
return Background
here is the important code from my level1.lua:
require "Background"
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
-- include Corona's "physics" library
local physics = require "physics"
physics.start(); physics.pause()
function scene:createScene( event )
local group = self.view
print("background 1:", Background)
local bkg = Background:new(50,50)
end
What is going wrong because the background shows, but for example the (50,50) positions do not work and I am getting the attempt to index global error [import]uid: 118839 topic_id: 22111 reply_id: 322111[/import]
