Today, there is a problem, click on a button, the layer where the button is removed from scene:
1 LocalClick =function(Event)2 LocalStartscene=require("App/scenes/startscene")3 LocalTag =Event.target:getTag ()4 ifTag = =1 Then5 cc. Director:getinstance (): Endtolua ()6 ElseIfTag = =2 Then7 self:removefromparent ()8 End9 End
The code is running on Mac, and it's not a problem, the same code that runs on the Windows7 machine has collapsed, the simulator window and the Debug window are stuck. Later the problem code to focus on the self:removefromparent (), on-line search, said the use of delayed deletion, can prevent crashes, so the code self:removefromparent () changed to:
local delay=cc. Delaytime:create (0.1) local callf=cc. Callfunc:create (function (...) Self:removefromparent () end) self:runaction (CC. Sequence:create (DELAY,CALLF,nil))
No longer crashes.
quick3.5 removefromparent () causes a crash problem with Windows emulator