Thats the point i don’t get an error, here is a piece of the code.
function onLocalCollisionMacaco( self, event )
–numberChoiceOne = math.random(1,4)
macaco.moved = true
–macaco.move_direction = “nulo”
if(event.phase == “began”) then
–[[if(event.other.tag == LevelHelper_TAG.BLOCOS_D) then
if(numberChoiceOne == 1) then
if(macaco.move_direction ~= “down”) then
macaco.MoveDown = true
macaco.move_direction = “down”
end
end
if(numberChoiceOne == 2) then
if(macaco.move_direction ~= “up”) then
macaco.MoveUp = true
macaco.move_direction = “up”
end
end
if(numberChoiceOne == 3) then
if(macaco.move_direction ~= “right”) then
macaco.MoveRight = true
macaco.move_direction = “right”
end
end
if(numberChoiceOne == 4) then
if(macaco.move_direction ~= “left”) then
macaco.MoveLeft = true
macaco.move_direction = “left”
end
end
end–]]
if(event.other.tag == LevelHelper_TAG.BLOCOS_I) then
if(numberChoiceOne == 1 and macaco.move_direction ~= “down”) then
macaco.MoveDown = true
macaco.move_direction = “down”
print(“down”)
end
if(numberChoiceOne == 2 and macaco.move_direction ~= “up”) then
macaco.MoveUp = true
macaco.move_direction = “up”
print(“up”)
end
if(numberChoiceOne == 3 and macaco.move_direction ~= “right”) then
macaco.MoveRight = true
macaco.move_direction = “right”
print(“right”)
end
if(numberChoiceOne == 4 and macaco.move_direction ~= “left”) then
macaco.MoveLeft = true
macaco.move_direction = “left”
print(“left”)
end
end
end
end
macaco.enemy_macaco.collision = onLocalCollisionMacaco
macaco.enemy_macaco:addEventListener ( “collision”, macaco.enemy_macaco )
The macaco.enemy_macaco is my enemy and i change his direction aftter he collides,but i do that in the update:
numberChoiceOne = math.random(1,4)
if(macaco.moved == false) then
enemy_direction = “down”
macaco.movementDown()
end
if(macaco.MoveDown == true) then
macaco.movementDown()
end
if(macaco.MoveUp == true) then
macaco.movementUp()
end
if(macaco.MoveRight == true) then
macaco.movementRight()
end
if(macaco.MoveLeft == true) then
macaco.movementLeft()
end
[import]uid: 124611 topic_id: 25734 reply_id: 104419[/import]