The text not appears, where is the error?
code:
local W = display.contentWidth / 2
local H = display.contentHeight / 2
–schermata 1
local schermataMenuGroup
local play
– schermata 2
local circle
local circle1
local text
function main()
menuPrincipale()
end
function menuPrincipale()
schermataMenuGroup = display.newGroup()
play = display.newText(“Play!”, 0, 0, “Arial”, 30)
play.x = W
play.y = H
play:setTextColor(255,255,255)
play.name = “play”
play:addEventListener(“tap”, loadGame)
schermataMenuGroup:insert(play)
end
function loadGame(event)
if event.target.name == “play” then
– Transizione e rimozione del Listener
transition.to(schermataMenuGroup,{time = 0, alpha=0, onComplete = addGameScreen})
play:removeEventListener(“tap”, loadGame)
end
end
local function dragMe(event)
local t=event.target
if event.phase==“moved” then
t.x=event.x
t.y=event.y
end
end
function addGameScreen()
circle = display.newCircle(W, H-200, 30)
circle:setFillColor(2,227,112)
circle1 = display.newCircle(W, H+200, 50)
circle1:setFillColor(0, 0, 0, 0)
circle1.strokeWidth =3
text = display.newText("", 0, 0, “Arial”, 30)
text.x = W
text.y = H
circle:addEventListener( “touch”, dragMe)
end
local function hasCollidedCircle( circle, circle1 )
if ( circle == nil ) then --make sure the first object exists
return false
end
if ( circle == nil ) then --make sure the other object exists
return false
end
local dx = circle.x - circle1.x
local dy = circle.y - circle1.y
local distance = math.sqrt( dx*dx + dy*dy )
local objectSize = (circle1.contentWidth/2) + (circle.contentWidth/2)
if ( distance < objectSize ) then
return true
end
return false
end
if hasCollidedCircle then
text = “you win”
end
main()