in my code I try to display a ball.png image . When I press the start button and go into my app I see the outline of the ball for a sec then it is gone . Why is this happening what should I do to fix it .
level1.lua code:
local storyboard = require( "storyboard" ) local scene = storyboard.newScene() function scene:createScene( event ) local group = self.view local physics = require( "physics" ) physics.start() physics.setGravity(0, 7) -- display background image local background = display.newImage( "background.png" ) background.x = 10; background.y = 308 -- display ground image local ground = display.newImage( "ground.png" ) ground.x = 145; ground.y = 480 physics.addBody( ground, "static" , { friction=0.5, bounce=0.1 } ) -- create object local myObject = display.newRect( 0, 0, 100, 30 ) myObject:setFillColor( 0 ) myObject.x = 145; myObject.y = 400 physics.addBody( myObject, "kinematic" , { myObject, friction=0.5, bounce=1 } ) -- touch listener function function myObject:touch( event ) if event.phase == "moved" then self.x = event.x self.y = event.y end return true end -- make 'myObject' listen for touch events myObject:addEventListener( "touch", myObject ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 387 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 300 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 202 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 104 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 7 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = 50, -49 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = 135, -49 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x = 232 wall.y = -49 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x = 335 wall.y = -49 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.rotation = 90 wall.x = 325 wall.y = 3 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.rotation = 90 wall.x = 325 wall.y = 98 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x = 325 wall.y = 195 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.rotation = 90 wall.x = 325 wall.y = 292 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=1 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.rotation = 90 wall.x = 325 wall.y = 387 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=4 } ) local ball = display.newImageRect( "ball.png", 200, 200 ) ball.x = 200 ball.y = 200 group:insert(ball) group:insert(background) group:insert(ground) group:insert(myObject) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) group:insert(wall) end function scene:enterScene( event ) local group = self.view end function scene:exitScene( event ) local group = self,view end function scene:destroyScene( event ) local group = self.view end scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene
Thank you.