Hi happy
I try call runtime later and the error continue appearing.
If you wanna see my code, it’s here:
local composer = require( “composer” )
local scene = composer.newScene()
local widget = require (“widget”)
local function buttonHit(event)
composer.gotoScene( event.target.destination )
return true
end
– “scene:create()”
function scene:create( event )
local sceneGroup = self.view
local background = display.newImage( “campo-futebol.jpg”)
sceneGroup:insert(background)
–backButton
local backBtn = display.newText(“Back”, 0, 0, “Helvetica”, 38)
backBtn.x= 640
backBtn.y= 970
backBtn.destination = “menu”
backBtn:addEventListener(“tap”, buttonHit)
composer.removeScene(true)
sceneGroup:insert(backBtn)
– Limites do ecrã
local borderTop = display.newRect( 0, 0, 707, 1 )
borderTop:setFillColor( 0, 0, 0, 0) – make invisible
physics.addBody( borderTop, “static”, borderBodyElement )
sceneGroup:insert(borderTop)
local borderBottom = display.newRect( 0, 1000, 707, 1 )
borderBottom:setFillColor( 0, 0, 0, 0) – make invisible
physics.addBody( borderBottom, “static”, borderBodyElement )
sceneGroup:insert(borderBottom)
local borderLeft = display.newRect( 0, 1, 1, 1000 )
borderLeft:setFillColor( 0, 0, 0, 0) – make invisible
physics.addBody( borderLeft, “static”, borderBodyElement )
sceneGroup:insert(borderLeft)
local borderRight = display.newRect( 707, 1, 1, 1000 )
borderRight:setFillColor( 0, 0, 0, 0) – make invisible
physics.addBody( borderRight, “static”, borderBodyElement )
sceneGroup:insert(borderRight)
– Initialize the scene here.
– Example: add display objects to “sceneGroup”, add touch listeners, etc.
end
– “scene:show()”
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == “will” ) then
– Called when the scene is still off screen (but is about to come on screen).
local myCircle = display.newCircle(40, 40, 30)
physics.addBody (myCircle, “dynamic”, {density=1.0, friction=0.5, bounce=0.0 } )
myCircle:setFillColor ( 255, 0, 0)
myCircle.x = 580
myCircle.y = 435
sceneGroup:insert(myCircle)
local function circleTouch(event)
local touchedObject = event.target
–Mover circuloVermelho
if event.phase == “began” then
touchedObject.previousX = touchedObject.x
touchedObject.previousY = touchedObject.y
elseif event.phase == “moved” then
touchedObject.x = (event.x - event.xStart) + touchedObject.previousX
touchedObject.y = (event.y - event.yStart) + touchedObject.previousY
end
return true
end
myCircle:addEventListener( “touch”, circleTouch)
local trailprops = {x= 0, y = 0,r = 5} – r= tamanho do circulo do rasto
function redraw () – Desenha o rasto
Trail = display.newCircle( myCircle.x + trailprops.x, myCircle.y + trailprops.y, trailprops.r)
Trail:setFillColor (255, 0, 0)
myCircle:toFront( )
sceneGroup:insert(Trail)
end
Runtime:addEventListener( “enterFrame”, redraw )
elseif ( phase == “did” ) then
– Called when the scene is now on screen.
– Insert code here to make the scene come alive.
– Example: start timers, begin animation, play audio, etc.
end
end
– “scene:hide()”
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == “will” ) then
– Called when the scene is on screen (but is about to go off screen).
– Insert code here to “pause” the scene.
– Example: stop timers, stop animation, stop audio, etc.
elseif ( phase == “did” ) then
– Called immediately after scene goes off screen.
end
end
– “scene:destroy()”
function scene:destroy( event )
local sceneGroup = self.view
– Called prior to the removal of scene’s view (“sceneGroup”).
– Insert code here to clean up the scene.
– Example: remove display objects, save state, etc.
end
– Listener setup
scene:addEventListener( “create”, scene )
scene:addEventListener( “show”, scene )
scene:addEventListener( “hide”, scene )
scene:addEventListener( “destroy”, scene )
return scene