Tag: sprite sprite kit

如何在Sprite Kit中使用手指移动物体,目标C

我试图做一个游戏,我有一些SKSpriteNodes和用户可以用手指移动他们,我正在使用苹果的新雪碧套件。 要做到这一点,我尝试了一个技巧 – 放置一个精灵 – 手指是“X”(SKSpriteNode),当用户移动手指 – 改变这个X精灵的位置, 问题是只有当它不在运动时,才会碰到其他精灵,我希望其他精灵能够响应手指的当前速度 – 手指运动越快 – 碰撞应该越强。 你能帮我吗? 虽然我觉得这个技巧不是正确的方法,但我也是在发布代码。 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { if([touches count]==1) { self.X= [[SKSpriteNode alloc]initWithImageNamed:@"X"]; self.X.name= @"X"; UITouch *t= touches.allObjects[0]; self.X.position= [t locationInNode:self.GameNode]; self.X.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:20]; self.X.physicsBody.dynamic=YES; // Tried NO too… self.X.zPosition=1; [self.GameNode addChild:self.X]; } } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *t […]