Ciao ragazzi ecco il mio codice per il giocatore e la palla che interagiscono tra loro. Quello che voglio fare è applicare la forza alla palla come se il mio giocatore la stesse sparando. Voglio che la palla si allontani dal mio giocatore con forza. come posso applicare Impulse o forzare a questo. Ho provato molte volte ma sono un principiante con Sprite Kit.Apply Angular Impulse
- (void) Player {
_Player = [SKSpriteNode spriteNodeWithImageNamed:@"player1"];
_Player.xScale = 0.09;
_Player.yScale = 0.09;
_Player.position = CGPointMake(self.size.width/4, self.size.height/2);
_Player.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:_Player.size];
_Player.physicsBody.dynamic = NO;
[self addChild:_Player];
}
- (void) TheMethodForBall {
SKSpriteNode *sprites = [SKSpriteNode spriteNodeWithImageNamed:@"ball"];
sprites.xScale = 0.19;
sprites.yScale = 0.19;
sprites.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:sprites.size];
sprites.physicsBody.dynamic = YES;
sprites.physicsBody.affectedByGravity = NO;
sprites.physicsBody.allowsRotation = YES;
sprites.physicsBody.restitution = YES;
sprites.physicsBody.angularVelocity = 4;
sprites.physicsBody.usesPreciseCollisionDetection = YES;
[self addChild:sprites];
}
qualcuno può per favore votarmi così posso iniziare a votare le risposte che ottengo. grazie ho bisogno di almeno 15 reputazioni. Non posso mostrare i miei apprezzamenti per le risposte che ricevo. – Ray
è possibile effettuare come corretto, ma qui è un +1 per voi – DogCoffee
grazie amico sei fantastico. – Ray