我希望能在ios游戏中获得一些帮助。这是一个简单的游戏,我使用一个垂直滚动的tilemap。我通过触摸不同的位置移动我的精灵,并在那里出现精灵。但是我最近实现了滚动从下到上和滚动几秒后。我的精灵不再去触摸的位置,而是坚持到屏幕的底部。
这是我的NSLog的打印
2014-05-01 17:44:06.628 Toygame[3735:a0b] X location: 359.500000
2014-05-01 17:44:06.629 Toygame[3735:a0b] Y Location: 301.000000
2014-05-01 17:44:10.794 Toygame[3735:a0b] X location: 396.500000
2014-05-01 17:44:10.794 Toygame[3735:a0b] Y Location: 288.500000
2014-05-01 17:44:14.427 Toygame[3735:a0b] X location: 401.500000
2014-05-01 17:44:14.428 Toygame[3735:a0b] Y Location: 261.000000
2014-05-01 17:44:16.811 Toygame[3735:a0b] X location: 397.000000
2014-05-01 17:44:16.812 Toygame[3735:a0b] Y Location: 256.500000
2014-05-01 17:44:18.880 Toygame[3735:a0b] X location: 399.000000
2014-05-01 17:44:18.881 Toygame[3735:a0b] Y Location: 245.000000
2014-05-01 17:44:21.444 Toygame[3735:a0b] X location: 405.000000
2014-05-01 17:44:21.445 Toygame[3735:a0b] Y Location: 297.500000
2014-05-01 17:44:23.544 Toygame[3735:a0b] X location: 405.000000
2014-05-01 17:44:23.544 Toygame[3735:a0b] Y Location: 289.500000
似乎无法超过300 Y,无论屏幕有多高,我点击屏幕,因为它一直向上滚动,我的精灵只是出现在底部
感谢您提供的任何帮助
(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];
if (teleports>0 & actPower==1) {
_player.position=location;
NSLog(@"X location: %f", location.x);
NSLog(@"Y Location: %f",location.y);
teleports--;
actPower=0;
}
}
- (void)moveBg
{
if (_gameState!=PCGameStateStartingLevel)
{
[self enumerateChildNodesWithName:@"bg" usingBlock:
^(SKNode *node, BOOL *stop) {
SKSpriteNode * bg = (SKSpriteNode *) node;
// CGPoint bgVelocity = CGPointMake(-BG_POINTS_PER_SEC, 0.0);
CGPoint bgVelocity = CGPointMake( 0.0,-BG_POINTS_PER_SEC);
CGPoint amtToMove = CGPointMultiplyScalar(bgVelocity, _dt);
bg.position = CGPointAdd(bg.position, amtToMove);
}];
}
}