I have created an app that has continuous flow of 'stone' nodes falling from the sky in two different sizes . The player controls a third stone object and depends on how it is collected from two falling stone types. Finally, a beam object acts as a moving ground. So far, I have detected a confrontation in my app, which detects conflicts between different stones and beams. This is my collision code:
Static Constance uint32_t stoneCategory = 1; Static const uint32_t beamCategory = 2; Static const uint32_t stoneCategory2 = 4; Contact
and
- (zero) Bid contact: (SKPSisCactact *) {SCFixixBody * First Body; SKFishixBody * SecondBody; CGPoint ContactPoint = Contact Contactpoint; Float contact_x = Contact Point.x; Boat contact_y = contact Point.y; If (contact.bodyA.categoryBitMask & lt; contact.bodyB.categoryBitMask) {firstBody = contact.bodyA; Secondbild = contact BB; } And {firstBody = contact.bodyB; Second Body = Contact A A; } // The first condition: if moving ahead, make a big stone rod for ((firstBody.categoryBitMask & stoneCategory) = 0!) {SKPhysicsJointFixed * composite = [SKPhysicsJointFixed jointWithBodyA: contact.bodyA bodyB: contact.bodyB Anchor: CGPointMake (contact_x, contact_y)]; [Self. Phishics World joint: United]; } // Second Condition: Little stones thrown out of big stone on collision (! (FirstBody.categoryBitMask & stoneCategory) = 0 & amp; (secondBody.categoryBitMask & stoneCategory2) = 0) {NSLog (@ "Hit" ); [Self-starred ChildNodesWithName: Block using @ "stone": ^ (SKN * node, bolted * stop) {[node deletion format]; }]; }
This works perfectly expected when the big stone hits a beam object, it sticks to it and moves with it. Also, when large stones and small stones Colliding, small stone is removed from the scene. Although: Though I think that this is actually my code because it points to my stone method (called 'stone'), on collision between stones, I only want a specific small stone to be removed, No more small stones appear on the scene of that moment.
I do not understand how this can happen. To recapture: How can I remove a specific node, instead of extracting its entire method? I hope my question is clear, if necessary I would be happy to provide more details.
My stone method:
- (zero) addStone {SKSpriteNode * stone = [[SKSpriteNode alloc] initWithColor: [SKColor grayColor] Size: CGSizeMake (12, 12 )]; Stone.position = CGExMake (Scorred (0, Self size.width), Self size. High + 12); Stone.name = @ "Stone"; Stone.physicsBody.categorishMask = stoneCategory2; Stone.physicsBody.contactTestBitMask = stoneCategory; Stone.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize: stone.size]; Stone.physicsBody.usesPreciseCollisionDetection = Yes; [Self-combine: stone]; }
and in my createSceneContents
SKAction * makeStone = [SKAction sequence: @ [[SKAction performSelector: @selector (addStone) onTarget: Self], [Scouting Waiting: 0.30 with Range: 0.25]];; [Speak run action: [suspension repeat anaccess: meststone]];
Above my small stone method is for big, I use a comparable method, but with its other names.
The reason behind this is 1) The order also happens
So when you first remove a small stone and rest it again, it changes the A to B.
Check the specific body type on the contact code below if (([contact.bodyA.node.name is EqualToString: @ "big stone"] & amp; amp; contact .bodyb.node.name isEqualToString: @ "sm Allstone "] ({contact.bodyA.node.name isEqualToString: @" smallstone "] & amp; amp; [contact.bodyB.node.name isEqualToString: @" big stone "])) {if ([ Contact.bodyA.node.name is EqualToString: @ "small stone"]) {{contact.bodyA.node removeFromParent]; } And {{contact.bodyB.node removeFromParent]; }}
Comments
Post a Comment