1.  
  2.  
  3. local background1 = display.newImage("bg.jpg",display.contentWidth,display.contentHeight)
  4. background1.x=display.contentCenterX
  5. background1.y=display.contentCenterY
  6. background1.alpha=0.8
  7.  
  8. local background2 = display.newImage("bg.jpg",display.contentWidth,display.contentHeight)
  9. background2.x=display.contentCenterX
  10. background2.y=360*2
  11. background2.alpha=0.8
  12.  
  13. local platform1=display.newImageRect("platform.png",130,30)  -- x,y dimension
  14. platform1.x=100
  15. platform1.y=120
  16.  
  17. local platform2=display.newImageRect("platform.png",130,30)  -- x,y dimension
  18.  
  19. local platform3=display.newImageRect("platform.png",130,30)  -- x,y dimension
  20.  
  21. local platform4=display.newImageRect("platform.png",130,30)  -- x,y dimension
  22.  
  23.  
  24.  
  25. local ball= display.newImageRect("ball1.png",50,50)
  26. ball.x=display.contentCenterX
  27.  
  28. local physics=require("physics")
  29. physics.start()
  30. physics.addBody(ball,{friction=0,density=0.2,gravity=0.98})
  31.  
  32. local physics=require("physics")
  33. physics.start()
  34. physics.addBody(platform1,"static",{friction=0.3})
  35.  
  36. local physics=require("physics")
  37. physics.start()
  38. physics.addBody(platform2,"static",{friction=0.3})
  39.  
  40. local physics=require("physics")
  41. physics.start()
  42. physics.addBody(platform3,"static",{friction=0.3})
  43.  
  44. local physics=require("physics")
  45. physics.start()
  46. physics.addBody(platform4,"static",{friction=0.3})
  47.  
  48. print(display.contentHeight)
  49. function scrolldown(self,event)
  50.         if(self.y < -240) then
  51.      self.y=360*2
  52.  else
  53.         self.y=self.y-3   -- 30 fps scrolling
  54.     end
  55.  end
  56.  
  57.    background1.enterFrame=scrolldown
  58.    Runtime:addEventListener("enterFrame",background1)
  59.  
  60.    background2.enterFrame=scrolldown
  61.    Runtime:addEventListener("enterFrame",background2)
  62.  
  63.  
  64.    --apply linear force on touch
  65.   function movebars( self,event )
  66.        
  67.   end
  68.    
  69.   function ontouch(self,event)
  70.   -- print("ball:",ball.x,ball.y)
  71.     if(self.x > display.contentWidth/2 )then
  72.         ball.x=ball.x+1
  73.    else
  74.        ball.x=ball.x-1
  75.    end
  76.   end
  77.  
  78.    Runtime:addEventListener("touch",ontouch)