现在我有一个游戏涉及一个永远反弹的角色,我的代码将在下面。但是,当我点击屏幕(toucehsbegan)时,我希望它是这样,它将使角色从任何地方落到,并在碰撞后恢复到正常的跳跃高度。再次感谢(抱歉,我是编码的新手)
我的角色:
person = [SKSpriteNode spriteNodeWithImageNamed:@"character"];
person.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:person.size];
person.physicsBody.dynamic = YES;
person.position = CGPointMake(80, 365);
person.physicsBody.restitution = 1;
person.physicsBody.linearDamping=0.02f;
[self addChild:person];
为了我的理由:
ground = [SKSpriteNode spriteNodeWithImageNamed:@"ground.png"];
ground.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:ground.size];
ground.physicsBody.dynamic = NO;
ground.position = CGPointMake(CGRectGetMidX(self.frame),200);
[self addChild:ground];
答案 0 :(得分:0)
从我的头脑中,我会做类似的事情:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
character.physicsBody.collisionBitMask = 0;
}