why does when I execute the code the screen goes black? [lua] local composer = require (“composer”); local scene = composer.newScene(); w, h = display.contentWidth, display.contentHeight local background local message local house local ball local can local shadowHouse local shadowBall local shadowCan local function hasCollided( obj1, obj2 ) if ( obj1 == nil ) then return false end if ( obj2 == nil ) then return false end local left = obj1.contentBounds.xMin <= obj2.contentBounds.xMin and obj1.contentBounds.xMax >= obj2.contentBounds.xMin local right = obj1.contentBounds.xMin >= obj2.contentBounds.xMin and obj1.contentBounds.xMin <= obj2.contentBounds.xMax local up = obj1.contentBounds.yMin <= obj2.contentBounds.yMin and obj1.contentBounds.yMax >= obj2.contentBounds.yMin local down = obj1.contentBounds.yMin >= obj2.contentBounds.yMin and obj1.contentBounds.yMin <= obj2.contentBounds.yMax return (left or right) and (up or down) end local function dragHouse(event) local target = event.target local phase = event.phase if (event.phase == “began”) then local parent = target.parent display.getCurrentStage() : setFocus(target) target.isFocus = true target.x0 = event.x - target.x target.y0 = event.y - target.y target.xStart = target.x target.yStart = target.y target:toFront() elseif (target.isFocus) then if (phase == “moved”) then target.x = event.x - target.x0 target.y = event.y - target.y0 if( hasCollided ( event.target, shadowHouse ) ) then transition.to( event.target, {time = 250, x = shadowHouse.x, y = shadowHouse.y} ) audio.play(sound2) phase = “cancelled” else end elseif ( phase == “ended” or phase == " cancelled") then display.getCurrentStage() : setFocus(nil) target.isFocus = false end end return true end local function dragBall( event ) local target = event.target local phase = event.phase if ( event.phase == “began” ) then local parent = target.parent display.getCurrentStage():setFocus(target) target.isFocus = true target.x0 = event.x - target.x target.y0 = event.y - target.y target.xStart = target.x target.yStart = target.y target:toFront() elseif ( target.isFocus ) then if ( phase == “moved” ) then target.x = event.x - target.x0 target.y = event.y - target.y0 if ( hasCollided( event.target, shadowBall ) ) then transition.to( event.target, {time=250, x=shadowhouse2.x, y=shadowhouse2.y} ) audio.play(sound2) phase=“cancelled” else end elseif ( phase == “ended” or phase == “cancelled” ) then display.getCurrentStage():setFocus( nil ) target.isFocus = false end end return true end local function dragCan(event) local target = event.target local phase = event.phase if ( event.phase == “began” ) then local parent = target.parent display.getCurrentStage():setFocus( target ) target.isFocus = true target.x0 = event.x - target.x target.y0 = event.y - target.y target.xStart = target.x target.yStart = target.y target:toFront() elseif ( target.isFocus ) then if ( phase == “moved” ) then target.x = event.x - target.x0 target.y = event.y - target.y0 if ( hasCollided( event.target, shadowCan ) ) then transition.to( event.target, {time=250, x=shadowhouse3.x, y=shadowhouse3.y} ) audio.play(sound2) phase=“cancelled” else end elseif ( phase == “ended” or phase == “cancelled” ) then display.getCurrentStage():setFocus( nil ) target.isFocus = false end end return true end function scene:create (event) local sceneGroup = self.view background = display.newImageRect(“sceneBG.png”, 768, 1024); background.x = w / 2 background.y = h / 2 sceneGroup:insert(background) message = display.newText(“Game 3”, 250, 250, nil, 60) message.x = w / 2 message.y = h / 12 sceneGroup:insert(message) house = display.newImage(“house_red.png”) house.x = 160 house.y = 300 sceneGroup:insert(house) house.myName = “house” shadowHouse = display.newImage(“house_red.png”) shadowHouse.x = 300 shadowHouse.y = 300 shadowHouse:setFillColor(50, 50, 50) shadowHouse.alpha = 0.75 sceneGroup:insert(shadowHouse) shadowHouse.myName = “house” shadowHouse.collision = onLocalCollision ball = display.newImage(“ball_blue.png”) ball.x = 160 ball.y = 400 sceneGroup:insert(ball) ball.myName = “ball” shadowBall = display.newImage(“ball_blue.png”) shadowBall.x = 300 shadowBall.y = 400 shadowBall:setFillColor(50, 50, 50) shadowBall.alpha = 0.75 sceneGroup:insert(shadowBall) shadowBall.myName = “ball” shadowBall.collision = onLocalCollision can = dsiplay.newImage(“soda_can.png”) can.x = 160 can.y = 500 sceneGrouproup:insert(can) can.myName = “can” shadowCan = display.newImage(“soda_can.png”) shadowCan.x = 300 shadowCan.y = 500 shadowCan:setFillColor(50, 50, 50) shadowCan.alpha = 0.75 sceneGroup:insert(shadowCan) shadowCan.myName = “can” shadowCan.collision = onLocalCollision end function scene:show(event) local sceneGroup = self.view composer.removeAll() message:setTextColor(255, 0, 0) sound2 = audio.loadSound(“boing_wav.wav”) house:addEventListener(“touch”, dragHouse) shadowHouse:addEventListener(“collision”, shadowHouse) ball:addEventListener(“touch”, dragBall) shadowBall:addEventListener(“collision”, shadowBall) can:addEventListener(“touch”, dragCan) shadowCan:addEventListener(“collision”, shadowCan) end function scene:hide(event) local sceneGroup = self.view house:removeEventListener(“touch”, dragHouse) shadowHouse:removeEventListener(“collision”, shadowHouse) ball:removeEventListener(“touch”, dragBall) shadowBall:removeEventListener(“collision”, shadowBall) can:removeEventListener(“touch”, dragCan) shadowCan:removeEventListener(“collision”, shadowCan) end function scene:destroy(event) local sceneGroup = self.view end scene:addEventListener(“create”, scene) scene:addEventListener(“show”, scene) scene:addEventListener(“hide”, scene) scene:addEventListener(“destroy”, scene) return scene [/lua]
Gonna go out on a limb here and say composer.removeAll() is your problem. just from a quick glance at your code it looks like you create everything and then before it is shown you nuke it try removing that line.
Also, I was not aware that composer had a function called removeAll() I know that storyboard did howerver and surprised your console isn’t showing errors.
I see thank you . . , I didn’t know that ^.^
Gonna go out on a limb here and say composer.removeAll() is your problem. just from a quick glance at your code it looks like you create everything and then before it is shown you nuke it try removing that line.
Also, I was not aware that composer had a function called removeAll() I know that storyboard did howerver and surprised your console isn’t showing errors.
I see thank you . . , I didn’t know that ^.^