I have a code like this
local storyboard = require( “storyboard” )
local widget = require “widget”
local scene = storyboard.newScene()
local image, text1, memTimer, wallFloor, wallTop, wallLeft, wallRightBottom, wallRightTop, wallScape
local ladyBug
local function movePlace()
storyboard.gotoScene( “level1Q14”, “crossFade”, 500 )
return true
end
local function dragBody ( event )
local body = event.target
local phase = event.phase
local stage = display.getCurrentStage ( )
if “began” == phase then
stage:setFocus ( body, event.id )
body.isFocus = true
body.tempJoint = physics.newJoint ( “touch”, body, event.x, event.y )
elseif body.isFocus then
if “moved” == phase then
body.tempJoint:setTarget ( event.x, event.y )
elseif “ended” == phase or “cancelled” == phase then
stage:setFocus (body, nil)
body.isFocus = false
body.tempJoint:removeSelf ( )
end
end
return true
end
--------------------------------------------------------------CREATE SCENE----------
function scene:createScene( event )
local screenGroup = self.view
local physics = require (“physics”)
physics.start()
image = display.newImage( “backgroundPlayLadyBug.png” )
screenGroup:insert( image )
image.x = 509
image.y = 384
wallFloor = display.newImage( “wallFloor.png” )
screenGroup:insert( wallFloor )
wallFloor.x = 512
wallFloor.y = 759
wallTop = display.newImage( “wallTop.png” )
screenGroup:insert( wallTop )
wallTop.x = 512
wallTop.y = 5
wallLeft = display.newImage( “wallLeft.png” )
screenGroup:insert( wallLeft )
wallLeft.x = 5
wallLeft.y = 380
wallRightBottom = display.newImage( “wallRightBottom.png” )
screenGroup:insert( wallRightBottom )
wallRightBottom.x = 1020
wallRightBottom.y = 495
wallRightTop = display.newImage( “wallRightTop.png” )
screenGroup:insert( wallRightTop )
wallRightTop.x = 1020
wallRightTop.y = 90
wallScape = display.newImage( “wallLadyBugScape.png” )
screenGroup:insert( wallScape )
wallScape.x = 1020
wallScape.y = 212
text1 = display.newText( “Help the LadyBug scape!”, 0, 0, nil, 20 )
text1:setTextColor( 255 )
text1:setReferencePoint( display.CenterReferencePoint )
text1.x, text1.y = display.contentWidth * 0.5, 50
screenGroup:insert( text1 )
end
--------------------------------------------------------------ENTER SCENE----------
function scene:enterScene( event )
local group = self.view
storyboard.purgeScene( “home” )
buttonB = widget.newButton{
defaultFile=“buttonHome.png”,
onRelease = movePlace
}
buttonB.x = 500
buttonB.y = 695
group:insert ( buttonB )
ladyBug = display.newImage (“ladyBugSmall.png”)
ladyBug.x = 200
ladyBug.y = 600
physics.addBody (wallFloor, “static”)
physics.addBody (wallTop, “static”)
physics.addBody (wallLeft, “static”)
physics.addBody (wallRightBottom, “static”)
physics.addBody (wallRightTop, “static”)
physics.addBody (ladyBug, “dynamic”, {density=9, friction=-0.8 , bounce = 0.4})
ladyBug:addEventListener (“touch”, dragBody)
end
--------------------------------------------------------------EXIT SCENE----------
function scene:exitScene()
--cat:removeEventListener (“touch”, dragBody)
ladyBug:removeEventListener (“touch”, dragBody)
--display.remove ( cat )
display.remove ( wallFloor )
display.remove ( wallScape )
display.remove ( ladyBug )
display.remove ( wallTop )
display.remove ( wallLeft )
display.remove ( wallRightBottom )
display.remove ( wallRightTop )
end
--------------------------------------------------------------DESTROY SCENE----------
function scene:destroyScene( event )
if buttonB then
buttonB:removeSelf()
buttonB = nil
end
end
– END OF YOUR IMPLEMENTATION
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene
The first time I go to this gameScene, the game (or the code) runs perfect!
When I go to another scene and then I come back to the same GameScene
that’s when I have this message:
File: …sers/victormbarba/Desktop/Piano For Kids/working.lua
Line: 113
Bad argument #-1 to ‘addBody’ (Proxy expected, got nil)
I found one article that tells me to copy the proxy.lua file and drop it in my folder, I did and didn’t work!
Could you please help me out and tell me what am I doing wrong,
This is all I need to finish my app.
Thanks
Victor