Update 2024-03-27: Greatly expanded the "Samples" page and renamed it to "Glossary".
Update 2024-04-04: Added 5 million mid-2011 posts from the k47 post dump. Browse (mostly) them here.
Update 2024-04-07: Added ~400 October 2003 posts from 4chan.net. Browse them here.

Welcome to Oldfriend Archive, the official 4chan archive of the NSA. Hosting ~170M text-only 2003-2014 4chan posts (mostly 2006-2008).
[11 / 0 / ?]

[1395255322] corona sdk programming

No.958034 View ViewReplyOriginalReport
Please I need some expert's help in checking/modifying the codes below so they work! For now the problem is when ball hits the balloons, the balloons won't disappear. The cannonball hits it and disappears.

function scene:createScene(event)
 local group = self.view
 
background = display.newImage( "bkg_clouds.png")
group:insert(background)
background.x = 230
background.y = 195
 
scoreText = display.newText( "0", 0, 0, native.systemFont, 32 )
scoreText:setFillColor( 0,0, 0 )
scoreText.x = 87
scoreText.y = 28
group:insert( scoreText )

questionText = display.newText('a', display.contentCenterX, display.contentWidth/4, native.systemFont, 40)
group:insert(questionText)

infoBar = display.newImage ("infoBar.png")
group:insert(infoBar)
infoBar.x = 10
infoBar.y = 25
 
restartBtn = display.newImage ("restartBtn.png")
group:insert(restartBtn)
restartBtn.x = 470
restartBtn.y = 300
 
cannon = display.newImage ("cannon.png")
group:insert(cannon)
cannon.x = 10
cannon.y = 270
 
cannon.anchorX = 0.5
cannon.anchorY = 0.5
restartBtn.isVisible = true

         local balloon = display.newImage ('balloon_fat_red.png', 495, 125)
         group:insert(balloon)
         balloon = display.newImage ('balloon_fat_red.png', 495, 175)
         group:insert(balloon)
         balloon = display.newImage ('balloon_fat_red.png', 495, 225)
         group:insert(balloon)
        
         local balloonText1 = display.newText('\227\129\130', 495, 125)
         balloonText1:setFillColor( 1,1, 0 )
         local balloonText2 = display.newText('\227\129\132', 495, 170)
         balloonText2:setFillColor( 1,1, 0 )
         local balloonText3 = display.newText('\227\129\134', 495, 225)
         balloonText3:setFillColor( 1,1, 0 )
        
         balloon.name = 'balloon'
         physics.addBody(balloon)
         balloon.bodyType = 'static'
         table.insert(balloons, balloon)        
       
         group:insert(balloonText1)
         group:insert(balloonText2)
         group:insert(balloonText3)



function ballCollision(e)
   if (e.other.name == 'balloon') then
            scene.updateScore()
            e.target:removeSelf()
            print ('remove balloon text')
            e.other:removeSelf()
            audio.play(pop)
        end
    end
   
function cannonCharge:touch(e)
  if(e.phase == 'began') then
        impulse = 0
        cannon.isVisible = true
        Runtime:addEventListener('enterFrame', charge)
    end
end
function charge()

local degreesPerFrame = 0.5
cannon.rotation = cannon.rotation - degreesPerFrame
     impulse=impulse-0.2
    
     if(cannon.rotation < -46) then
          cannon.rotation = -46
          impulse = -3.2
        end
end
function shot:touch(e)
    if(e.phase == 'ended') then
    
        Runtime:removeEventListener('enterFrame', charge)
        cannon.isVisible = true
        cannon.rotation = 0
       
        cannonBall = display.newImage('cannon ball.png', 84, 220)
        physics.addBody(cannonBall, {density = 1, friction = 0, bounce = 0})
        group:insert(cannonBall)
    
-- Shoot cannon ball
cannonBall:applyLinearImpulse(3, impulse, cannonBall.x, cannonBall.y )

--Collision listener
cannonBall:addEventListener ('collision', ballCollision)
   
    end
end


end