And again i don’t understand what’s wrong. This code looks fine (because Corona shown not any errors):
--bg4 start ----------------------------------------------------------------------------------------- local imgW = display.contentWidth local imgH = display.contentHeight local scrollSpeed = -1.5 --bg4 move local bg4a = display.newImageRect("img/bg/bg4.png", 1024, 768) bg4a.x = imgW\*0.5; bg4a.y= imgH/2.4; local bg4b = display.newImageRect("img/bg/bg4.png", 1024, 768) bg4b.x = imgW\*1.5; bg4b.y= imgH/2.4; local bg4c = display.newImageRect("img/bg/bg4.png", 1024, 768) bg4c.x = imgW\*2.5; bg4c.y= imgH/2.4; local moveBool = true if moveBool == true then local function move( event ) -- move backgrounds to the left by scrollSpeed, default is 2 bg4a.x = bg4a.x + scrollSpeed bg4b.x = bg4b.x + scrollSpeed bg4c.x = bg4c.x + scrollSpeed -- Set up listeners so when backgrounds hits a certain point off the screen, -- move the background to the right off screen if bg4a.x \< -512 then bg4a:translate( 2048, 0 ) end if bg4b.x \< -512 then bg4b:translate( 2048, 0 ) end if bg4c.x\< -512 then bg4c:translate( 2048, 0 ) end end -- Create a runtime event to move backgrounds Runtime:addEventListener( "enterFrame", move ) end if moveBool == false then local function move( event ) -- move backgrounds to the left by scrollSpeed, default is 2 bg4a.x = bg4a.x + 0 bg4b.x = bg4b.x + 0 bg4c.x = bg4c.x + 0 end -- Create a runtime event to move backgrounds Runtime:addEventListener( "enterFrame", move ) end return moveBool ----------------------------------------------------------------------------------------- --bg4 end
Further i’m try to connect it into main.lua with false state for moveBool (in bg4_move.lua above that’s true initially):
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- display.setStatusBar(display.HiddenStatusBar) --disable phone ui local physics = require( "physics" ) physics.start() --connect modules start ----------------------------------------------------------------------------------------- require ("bg1\_static") require ("bg2\_move") require ("bg3\_move") local player = require ("player\_run") player.x = player.x + 512 player.y = player.y + 510 local bg4 = require ("bg4\_move") bg4.moveBool = false ----------------------------------------------------------------------------------------- --connect modules end --player controls start ----------------------------------------------------------------------------------------- --local function PlrFastRun() --player:setSequence( "fastRun" ) --player:play() --end --player:addEventListener( "tap", PlrFastRun ) ----------------------------------------------------------------------------------------- local function PlrStopRun() player:setSequence( "stopRun" ) player:play() end player:addEventListener( "tap", PlrStopRun ) ----------------------------------------------------------------------------------------- --player contros end
And get an error (pic in attach). What’s i do wrong now?