so, i tried to use physics) why is this kind of thing not working? are physics cant detect collision while transitioning or is it because of the way “player” moves?
[lua]local player = display.newCircle(0,0,20)
player:setFillColor(255,0,0)
player.x = 50
player.y = _H-flor.height-player.height
player.visible = false
physics.addBody(player, “dynamic”)
player.name = “player”
local function going()
if left == 1 then
player.x = player.x - 3
end
if right == 1 then
player.x = player.x + 3
end
end
local npc = display.newCircle(0,0,25)
npc:setFillColor(0,255,0)
group:insert(npc)
physics.addBody(npc, “kinematic”)
local npc_rect = display.newRect(0,0,150,30)
group:insert(npc_rect)
npc_rect.x = npc.x
npc_rect.y = npc.y
physics.addBody(npc_rect, “kinematic”)
npc_rect.name = “rect”
function to_left()
if blo == true then
transition.to(group, {time=3000, x = group.x - 100, onComplete = to_right})
end
end
function to_right()
transition.to(group, {time=3000, x = group.x + 100, onComplete = to_left})
end
to_right()
local function onCollision(event)
if event.object1.name == “rect” and event.object2.name == “player” then
print(“lol”)
end
end
Runtime:addEventListener(“collision”, onCollision)[/lua]
any help is appreciated, i really need to understand this [import]uid: 16142 topic_id: 16946 reply_id: 63608[/import]