I have the following code:
if enemy and enemy~=nil then local angleXpos,angleYpos=enemy:localToContent( 0,0 ) end
Now I have changed something enemy related and delete enemies earlier which results in an error sometime. It than says localToContent is not known or something like this (I don’t have the exact error right now, but try to reproduce it for posting it here)
It is 99% because of the enemy being deleted and the function with the code above still called… BUT I thought the line
if enemy and enemy~=nil then
will prevent the localToContent getting called if an enemy is not there.
My question: Is there a better way to do this if statement?