The following code doesn't work as expected. For reason incomprehensible to me "monster intersect player" is never called. What's the matter here?
for monsterNode in self.children as [SKNode]{
if (monsterNode.name? == "monster") {
println("monster node found")
for playerNode in self.children as [SKNode]{
if (playerNode.name? == "player"){
println("player found")
if(monsterNode.intersectsNode(playerNode)){
println("monster intersects player")
}
}
}
}
}
For one player node and three monster nodes where the player node is intersecting a monster node, the following is printed:
monster node found
player found
monster node found
player found
monster node found
player found