ios - How to make object change in contact -
I have an object in that scene that determines:
SKSpriteNode * object = [ssptn node phantom nodivith: fiction: _bovac]; [Object set: 2]; Object.position = CG Pointsmake (0, Y); object.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize: object.size]; Object.physicsBody.dynamic = NO; Then if my character hits it, then he will be there. Now, I want that whenever the object is hit on the object, the object also moves its upper half. If index value is in class 2, then in the index value class 2, in the case of object and character reflection by normal physical contact law, if the index value is in class 3, the object is broken in half
I tried to put
object.physicsBody.dynamic = yes; Then I saw that it pulled down and disappeared from gravity. How do I set up an object dynamic and condition to meet the above requirement? Thank you very much for your help!
Added (as requested): My Representative Method:
@ interface Messenci () & lt; SKFX Contact Delegate & gt; {SKSpriteNode * _character; Scalcons * _object1; Scalcons * _bob2; SKAction * _moveObjects; SKNode * _moving; SKNode * _objects; BOOL _canRestart; NSInteger _index; Scalcons * character syntax; SKSpriteNode * _characterSprite; Later part (not sure that it is relevant) - (id) initWithSize: (CGSize) size {if (self = [super initWithSize: size]) {/ Setup view Here / / self.physicsWorld.gravity = CGVectorMake (0.0, -6.0); self.physicsWorld.contactDelegate = self; My objects are moved on the scans in such a way:
CGFlot distanceTomaw = self.frame.size.width + 2 * _object1.size .width; SKAction * moveObjects = [SKAction moveByX: -DistanceToMove y: 0 duration: 0.01 * distance etomov]; SKAction * removeObjects = [SKAction removeFromParent]; _moveObjectsAndRemove = [SKAction sequence: @ [moveObjects, removeObjects]]; Ps: add didBeginContact:
- (zero) done with binconfident: (SKPSIS contact *) contact {if (_moving.speed> 0) {// score node if ((contact.bodyA.categoryBitMask and scoreCategory) == Score Range (contact.baB.categoryBitMask and scoreCategory) == scoreCategory) {_score ++; // Add a short view [_scoreLabelNode running action: [SKACACE Sequence: @ [[SKAPA Scale: 1.5 Duration: 0.1], [SKAP Scale: 1.0 Duration: 0.1]]]] ;; } And // collided with the world {_moving.speed = 0; _character.physicsBodyCollisionBitMask = worldCategory; [_chart run action: [scouting rotatebangent: mopi * _treatctoji.e.e. 0.01 Period: _CharacturesCo.A. * 0.03] Closing: ^ {_ character.speed = 0; }];
You need to set
object. physicsBody.affectedByGravity = NO;
Comments
Post a Comment