I have the following code in which when the player physics body collides with the sensor body, a new physics body is spawned.
The new body is created but I get a
"Assertion failed. Expression:isLocked == false() "
error and Corona crashes…
[lua]physics = require “physics”
physics.start()
physics.setGravity(0,10)
ground = display.newRect(100,400,500,51);
physics.addBody(ground,“static”)
player = display.newRect(100,340,100,100); player.x = 100; player.y =340;
physics.addBody(player)
sensor = display.newRect(300,0,20,800)
sensor.name = “sensor”
physics.addBody(sensor,“static”,{isSensor = true})
local onEnterFrame = function(event)
player.x = player.x + 5
end
Runtime:addEventListener(“enterFrame”,onEnterFrame)
local onCollide = function(self,event)
if(event.other.name == “sensor”) then
dynamic = display.newRect(700,340,100,100)
physics.addBody(dynamic,“static”)
end
end
player.collision = onCollide
player:addEventListener(“collision”,player)[/lua]
If I click on ignore… corona continues… What must I do to avoid this error? [import]uid: 64174 topic_id: 12544 reply_id: 312544[/import]