2013-11-24 74 views
0

我正在研究(测试)游戏以学习SpriteKit试图制作我自己的纸牌游戏。雪碧未正确定位

我正在创建一个应该由SKAction移动出来的侧栏,它是自己运行的动画。我为iPhone和iPad创建了一个正确尺寸的黑色条,名为“backmenu〜iphone.png”(50p)和“backmenu〜ipad.png”(100p)。

我遇到的问题是我能够在iPhone上正确定位黑条而不是在iPad上,它被定位为低位,我无法弄清楚我做错了什么。我确实设置了锚点并将精灵放置在相同的坐标上。精灵是正确的大小。

的代码:

SKSpriteNode *menuOnMainScreen = [SKSpriteNode spriteNodeWithImageNamed:@"backmenu"]; 
     menuOnMainScreen.anchorPoint = CGPointMake(0.0, 0.1); 
     menuOnMainScreen.position = CGPointMake(_menuPositionOutsideOfScreen, 0); 
     menuOnMainScreen.name = @"backmenu"; 
     menuOnMainScreen.zPosition = 1000; 
     [self addChild:menuOnMainScreen]; 

     SKAction *moveMenuIntoScreen = [SKAction moveTo:CGPointMake(0, 0) duration:0.3]; 
     [menuOnMainScreen runAction:moveMenuIntoScreen]; 

     SKSpriteNode *arrowLeft = [SKSpriteNode spriteNodeWithImageNamed:@"arrow_left"]; 
     arrowLeft.anchorPoint = CGPointMake(0.5, 0.5); 
     arrowLeft.position = CGPointMake(_setWidthPositionInSideMenuCoordinate, CGRectGetMaxY(self.frame) * 0.95); 
     [menuOnMainScreen addChild:arrowLeft]; 

以下参数:

_menuPositionOutsideOfScreen = -50 iPhone上

_menuPositionOutsideOfScreen = -100 iPad上

当我运行它的代码如下,iPhone o n中的左和iPad上的权利:

iPhoneenter image description here

回答

0

我认为,问题是您anchorPoint“SY为0.1

它不应该是:

menuOnMainScreen.anchorPoint = CGPointMake(0,0); 
0

如果什么您在y方向制作定位点 0.5,0.5并将它们定位为self.size.height/2,并且_menuPositionOutsideOfScreen on x-direction?

它有点难以测试它没有更多的代码,但试试吧