I’m getting an error on “localGroup:insert(sun)”, “drawBackground”, and “gameInit” …
Why isn’t this working? If I take them out of functions, it works fine, but when I add them as functions ( saves memory?), it doesn’t work. Quite frustrating.
[code]
module(…, package.seeall)
function new()
local localGroup = display.newGroup()
system.activate( “accelerometer” )
system.activate( “multitouch” )
system.setIdleTimer(false)
display.setStatusBar( display.HiddenStatusBar )
– External Libraries
local movieclip = require “movieclip”
local ui = require “ui”
local physics = require “physics”
local widget = require “widget”
physics.start()
physics.setGravity(0,0)
local background
local leftwall
local sun
local fog
local fog2
local baseline = 280
local drawBackground = function()
background = display.newImage(“backgroundgame.png”)
background:setReferencePoint(display.TopLeftReferencePoint)
background.x = -45; background.y = 0
localGroup:insert(background)
sun = display.newImage(“sun”, 22, 19)
localGroup:insert(sun)
fog = display.newImage(“fog.png”)
fog:setReferencePoint( display.CenterLeftReferencePoint )
fog.x = 0; fog.y = baseline + 20
fog2 = display.newImage(“fog2.png”)
fog2:setReferencePoint( display.CenterLeftReferencePoint )
fog2.x = 480; fog2.y = baseline + 20
localGroup:insert(fog)
localGroup:insert(fog2)
tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time
local xOffset = ( 0.6 * tDelta )
sun.x = sun.x + xOffset * 0.03
fog.x = fog.x - xOffset
fog2.x = fog2.x - xOffset
if fog.x + fog.contentWidth < 0 then
fog:translate( 480 * 2, 0 )
end
if fog2.x + fog2.contentWidth < 0 then
fog2:translate( 480 * 2, 0 )
end
end
move()
end
local gameInit = function()
physics.start(true)
physics.setGravity( 0,0 )
drawBackground()
Runtime:addEventListener(“enterFrame”, move)
end
gameInit()
return localGroup
end [import]uid: 114389 topic_id: 30634 reply_id: 330634[/import]