-(void)tankDestroyed{ for (LHJoint*joint in [lh jointsWithTag:TANK]) { [joint removeSelf]; } for (LHJoint*wheelJoint in WheelArray) { [wheelJoint removeSelf]; } [WheelArray removeAllObjects]; for (__strong LHSprite*trackPart in TrackArray) { [trackPart pauseAnimation]; trackPart=nil; } [TrackArray removeAllObjects]; [WheelArray removeAllObjects]; barrel=nil; for (LHSprite*tankPart in [lh spritesWithTag:TANK]) { [tankPart setCollisionFilterMask:1]; [tankPart setCollisionFilterCategory:4]; [tankPart setCollisionFilterGroup:-4]; } }
First, all
joints attached to the tank (that have the tag tank), will all be destroyed.
All arrays that contained joints and objects are emptied, as keeping them would
cause the objects to not be removed properly and might even cause a crash. All
animations are stopped and the bodies’ collision bits are changed so they all
collide with the level. The result is an exploding tank, with pieces flying
everywhere.
Game Over! |
No comments:
Post a Comment