Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

crashoverride77

macrumors 65816
Original poster
Jan 27, 2014
1,234
213
Hey
I am quite new too coding and I hope someone can maybe clear me up.

1) Right after game scene I wrote

Code:
let worldBorder = SKNode()

2) In func didBeginContact I have this after the standard variables

Code:
if ((firstBody.categoryBitMask == physicsCategory.bullet) && (secondBody.categoryBitMask == physicsCategory.worldBorder) ||
            (firstBody.categoryBitMask == physicsCategory.worldBorder) && (secondBody.categoryBitMask == physicsCategory.bullet)) {
                
                collisionBulletWithWorldBorder([B]firstBody.node as! SKSpriteNode[/B], Bullet: secondBody.node as! SKSpriteNode)


Everything is working as expected because when the collision happens the "collisionBulletWithWorldBorder(WorldBorder:SKNode, Bullet:SKSpriteNode)" function is called which than removes my bullet.
(Bullet is not in game scene so I cannot just write bullet.removeFromParent() instead of the paragraph with the bold bit)

However if I try to change the code (bold) to ... as! SKNode, because my common sense tells me too, than it will not work anymore. Can someone explain why this bit is SKSpriteNode and not just SKNode.

Thanks for any help

SOLVED: just remove the whole collision bullet with world border line and replace it with Firstbody(or secondbody).node?.remove from parent. Duh
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.