Ios 如何制作';《公安条例》第27条;触摸屏幕时是否出现在某个位置?

Ios 如何制作';《公安条例》第27条;触摸屏幕时是否出现在某个位置?,ios,sprite-kit,Ios,Sprite Kit,我正在用雪碧套件为iphone做一个游戏,我是一个noob哈哈。无论如何,这是我到目前为止的代码,但是我希望它出现在我选择的地方,而不是我触摸的地方出现的便便 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { /* Called when a touch begins */ for (UITouch *touch in touches) { CGPoint location = [touch locat

我正在用雪碧套件为iphone做一个游戏,我是一个noob哈哈。无论如何,这是我到目前为止的代码,但是我希望它出现在我选择的地方,而不是我触摸的地方出现的便便

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
 /* Called when a touch begins */

for (UITouch *touch in touches) {
    CGPoint location = [touch locationInNode:self];

    SKSpriteNode *poo = [SKSpriteNode spriteNodeWithImageNamed:@"poo"];

    poo.position = location;

    poo.zPosition = 5;

    [poo setScale:0.2f];


    //next line adds gravity to the poo.
    poo.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:poo.size.width/2];

    [self addChild:poo];
}

}

只需创建一个带有所需位置的
CGPoint
,并将其设置为一个位置:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{
    CGPoint yourLocationOfChoice = CGPointMake(200.0f, 200.0f);

    SKSpriteNode *poo = [SKSpriteNode spriteNodeWithImageNamed:@"poo"];

    poo.position = yourLocationOfChoice;

    ...
}

您是否尝试将位置设置为其他位置?显式地告诉编译器您正在输入一个浮点数。