Hello guys, I’m having kind of an odd issue.
I’m basing my project off of the Corona Tutorial for the space shoot 'em up game, which contains the following function in order for the player to gain some invincibility frames upon getting hit, which works without any issues.
It’s contained within the game.lua file and, as such, the ship referenced in the function itself is a local variable.
local function restoreShip() ship.isBodyActive = false ship.x = display.contentCenterX ship.y = display.contentHeight - 100 -- Fade in the ship transition.to( ship, { alpha=1, time=4000, onComplete = function() ship.isBodyActive = true died = false end } ) end
This is my version of said function, contained within a module which I called shipManage.lua
shipManage.restoreShip = function (ship) ship.isBodyActive = false ship.x = display.contentCenterX ship.y = display.contentHeight \* 0.8 -- Fade in the ship transition.to( ship, { alpha = 1, time = 4000, onComplete = function() ship.isBodyActive = true end } ) end
It works well if I put it in my game.lua file (with the only alteration being, in that case, that the ship isn’t passed as a parameter to the function but is instead a local variable). However, if I put it in the shipManage.lua module, and pass the ship as a parameter to the function itself, I start getting the following error:
“property isBodyActive cannot be set cannot be called when the world is locked and in the middle of number crunching, such as during a collision event”
Which doesn’t make sense to me because the function, wether it’s in shipManage.lua or game.lua is called with the same exact delay in milliseconds (and altering it has proven to be useless).
Could somebody help me shed some light into this issue?