Hello everyone!
I have two problems with the same displayed text.
I set a text to appear after a collision occured which works fine.
Problem 1 = I can’t change the fill color of the text
Problem 2 = the text stays onscrene even after switching to other scenes
Here my code:
local myTextBox = display.newText( “Go…”, 100 ,50, 125, 25, robotoFont, 25 )
myTextBox:setFillColor( 1, 0, 0 )
physics.addBody(myTextBox, “dynamic”,{density=1, friction =.3})
physics.setGravity( 1, 10 )
myTextBox.name = “myTextBox”
local function onLocalCollision (self, event)
if event.phase == “began” then
display.remove (myTextBox)
myTextBox = nil
display.newText ( “…again!”, 200 ,200, 350, 25, robotoFont, 25)
--I cannot change default color of the text
--This text stays on screen even if changing scenes
score = score +1
updateText();
elseif ( “moved” == phase ) then
elseif event.phase == “ended” then
display.remove (newText) --This doesn’t work
newText = nil; --this doesn’t work either
end
end
myTextBox.collision = onLocalCollision
myTextBox:addEventListener(“collision”, myTextBox)
I also tried to remove newText in “hide or distroy” phase without any luck.
I appreciate any help
Thanks
Patricia