Thanks, it looks like it is running in the terminal (shows it moving between true and false) but it is not starting my animation on the screen. I think i need to tweek some other items! thanks for your help!!
this is my entire code to make a scrolling background
display.setStatusBar(display.HiddenStatusBar) – hides the status bar
– loads the physics engine into the game
local physics = require “physics”
physics.start()
physics.setGravity(0,9.8)
– gets the screen size of the game
local screenW = display.contentWidth
local screenH = display.contentHeight
local backgroundSpeed = 100
– game is nto active until it is tapped
local gameIsActive = false
– this object is to get the background the scroll
– create 2 background images to ensure they scroll
local BGspeed = 10
local background1
background1 = display.newImage(“images/mountainBG.png”)
background1.xReference = -480
background1.x = 0
local background2
background2 = display.newImage(“images/mountainBG.png”)
background2.xReference = -480
background2.x = 960
–background2.alpha = 0.5
– this function is what controls the background position and creates the movement
function updateBackgrounds()
if (gameIsActive == true) then
background1.x = background1.x - (BGspeed/5)
if(background1.x <= -960) then
background1.x = 960
end
background2.x = background2.x - (BGspeed/5)
if(background2.x <= -960) then
background2.x = 960
end
end
end
–this is how we call the update function, make sure that this line comes after the
–actual function or it will not be able to find it
–timer.performWithDelay(how often it will run in milliseconds, function to call, how many times to call(-1 means forever))
if gameIsActive == true then
timer.performWithDelay(1, updateBackgrounds, -1)
end
local touchBox = display.newRect(0, 0, 960, 640)
touchBox.alpha = 0
local someButton
local gameIsActive = false
someButton = display.newCircle( 200, 200, 50)
local function touchBox( event )
if ( gameIsActive == false ) then
gameIsActive = true
else
gameIsActive = false
end
– printing BOOL state in Terminal
print(string.format("–> gameIsActive = %s",tostring(gameIsActive)))
end
someButton.tap = touchBox
someButton:addEventListener( “tap”, someButton ) [import]uid: 39705 topic_id: 29187 reply_id: 117382[/import]