Problem with Score

Hi Dear

I developed one game "honey collector", it is working nice but once i am coming on menu page,again going to game that time it is Soing Error < like>::attempt to call method remove
Please help me

module(..., package.seeall)

local physics = require("physics")
score = require ("score")
physics.start(true)
physics.setGravity(0,9.8)
----------------------------------------------------------------------------------
function new()
local localGroup = display.newGroup()
----------------------------------------------------------------------------------

score.init({x = 40,y = 5})
score.setScore( 0 )

local bgimage = display.newImageRect ("gamebg.jpg",1024,768)
bgimage.x=512
bgimage.y=384
localGroup:insert(bgimage)

local tapSound=audio.loadSound("tapsound.wav")

local ground = display.newImage( "ground.png" )
ground.x = display.viewableContentWidth/2
ground.y = display.viewableContentHeight/1.05
ground.myName = "Ground"
physics.addBody( ground, "static",{friction=0.3})

local drpgnimg = display.newImage ("drpgn.png")
--physics.addBody( drpgnimg)
drpgnimg.myName = "Drop"
drpgnimg.isVisible=false

function honey()
local drpimg = display.newImage ("drop1.png")
drpimg.x= math.random(10,1000)
drpimg.y=-400
drpimg.myName = "Drop"
physics.addBody( drpimg, { density=0.9, friction=0.9} )
print("Droping a Drop")

local drpimg1 = display.newImage ("drop2.png")
drpimg1.x= math.random(10,1000)
drpimg1.y=-200
drpimg1.myName = "Drop1"
physics.addBody( drpimg1, { density=0.9, friction=0.6} )
print("Droping a Drop")

local drpimg2 = display.newImage ("drop3.png")
drpimg2.x= math.random(10,1000)
drpimg2.y=-10
drpimg2.myName = "Drop2"
physics.addBody( drpimg2, { density=0.9, friction=0.3} )
Showing Error Here::>> print("Droping a Drop")

function drpimg:collision (event)
if event.other.myName == "Jar" then
print "Drop into the Jar!"
drpimg:removeSelf()
score.setScore (score.getScore() + 10)

elseif event.other.myName == "Ground" then
print "Drop hit the Ground"
drpimg:removeSelf()
drpgnimg.isVisible=true
drpgnimg.x=drpimg.x
drpgnimg.y=display.viewableContentHeight/1.05
score.setScore (score.getScore() - 5)
end
end
drpimg:addEventListener("collision", drpimg)

function drpimg1:collision (event)
if event.other.myName == "Jar" then
print "Drop into the Jar!"
drpimg1:removeSelf()
score.setScore (score.getScore() + 8)

elseif event.other.myName == "Ground" then
print "Drop hit the Ground"
drpimg1:removeSelf()
drpgnimg.isVisible = false
drpgnimg.x=drpimg1.x
drpgnimg.y=display.viewableContentHeight/1.05
score.setScore (score.getScore() - 4)
end
end
drpimg1:addEventListener("collision", drpimg1)

function drpimg2:collision (event)
if event.other.myName == "Jar" then
print "Drop into the Jar!"
drpimg2:removeSelf()
score.setScore (score.getScore() + 6)

elseif event.other.myName == "Ground" then
print "Drop hit the Ground"
drpimg2:removeSelf()

drpgnimg.isVisible=true
drpgnimg.x=drpimg2.x
drpgnimg.y=display.viewableContentHeight/1.05
score.setScore (score.getScore() - 3)
end
end
drpimg1:addEventListener("collision", drpimg2)
end

local dropHoney = timer.performWithDelay( 1500, honey, -1 )

local jarimg = display.newImage ("jar.png")
jarimg.x=display.viewableContentWidth/2
jarimg.y=display.viewableContentHeight/1.1
jarimg.myName = "Jar"
physics.addBody( jarimg, { density=0.9, friction=0.3} )
jarimgisVisible=true

local function drag (event)
jarimg.x = event.x
end
jarimg:addEventListener ("touch", drag)

local menubtn = display.newImage ("menu.png")
menubtn.x=display.viewableContentWidth/1.2
menubtn.y=display.viewableContentHeight/10
localGroup:insert(menubtn)

local pausebtn = display.newImage ("pause.png")
pausebtn.alpha=0
pausebtn.x=display.viewableContentWidth/1.08
pausebtn.y=display.viewableContentHeight/10
transition.to(pausebtn,{time=3500,delay=500,alpha=1})
localGroup:insert(pausebtn)

local playbtn = display.newImage ("play.png")
playbtn.alpha=0
playbtn.x=display.viewableContentWidth/1.08
playbtn.y=display.viewableContentHeight/10
transition.to(playbtn,{time=3500,delay=500,alpha=1})
localGroup:insert(playbtn)

menubtn.isActive=false
menubtn.isVisible=false
playbtn.isActive=false
playbtn.isVisible=false

local function fmenu (event)
if event.phase == "ended" then
bg:removeSelf()
audio.play( tapSound )
director:changeScene ("menu")
print("menu")
end
end
menubtn:addEventListener ("touch", fmenu)

local function fpause (event)
if event.phase == "ended" then
bg=display.newRect(0,0,1024,768)
bg:setFillColor(0,0,0,125)
menubtn.isActive=true
menubtn.isVisible=true
playbtn.isActive=true
playbtn.isVisible=true
pausebtn.isActive=false
pausebtn.isVisible=false
--jarimg.isVisible = false
physics.pause()
timer.cancel(dropHoney)
audio.play( tapSound )
print("pause")
end
end
pausebtn:addEventListener ("touch", fpause)

local function fresume (event)
if event.phase == "ended" then
bg:removeSelf()
menubtn.isActive=false
menubtn.isVisible=false
playbtn.isActive=false
playbtn.isVisible=false
pausebtn.isActive=true
pausebtn.isVisible=true
--jarimg.isVisible = true
audio.play( tapSound )
dropHoney = timer.performWithDelay( 1500 , honey , -1 )
physics.start()
print("resume")
end
end
playbtn:addEventListener ("touch", fresume)

return localGroup
end

views:1162 update:2011/11/17 9:28:17
corona forums © 2003-2011