![]() Manipulating bit masks to turn collision & contacts off and on.Įdit: SK demo showing an object hitting a wall made up of blocks:Ĭreate a new SK project and use this as the GameScene,swift: import SpriteKit Then the wall nodes will be affected by the collision (and move or spin away) and your didBegin() will be called and you can run an action on each wall node comprising of the animation you want and ending with removeFromParent().Ī guide to collision and contactTest bit masks: When the player has the power-up, make the wall nodes affected by the collision and also turn on contacts between the player and the wall (it's enough just to turn on the bit for the wall category in the player's contactTestBitMask). Then when the player hits the wall, the player will be affected by the collision (and bounce off) but the wall nodes will be unaffected. If the player doesn't have the power-up, turn off the bit for the player in the wall nodes' physicsBodies collisionBitMask so that the wall nodes do not collide with the player. If you want to see how to use arcade physics, I strongly recommend checking out my previous tutorial which uses the same example.You don't need to have the nodes making up the wall held together in any way - just place them on the screen.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |