精灵套件变形纹理?

时间:2013-12-10 14:17:52

标签: ios sprite-kit

我正试图让一个火柴人走动。但是,当我为其纹理图集设置动画时,第二个图像会变形并沿x轴拉伸。以下是设置场景的代码:

-(id)initWithSize:(CGSize)size {    
    if (self = [super initWithSize:size]) {
        /* GROUND */

        self.backgroundColor = [SKColor colorWithRed:0 green:1 blue:1 alpha:1.0];

        CGFloat groundHeight = (size.height / 2) - 50;

        CGSize groundSize = CGSizeMake(size.width, groundHeight);

        SKSpriteNode *ground = [SKSpriteNode spriteNodeWithColor:[UIColor lightGrayColor] size:groundSize];

        ground.position = CGPointMake(CGRectGetMidX(self.frame), (groundHeight / 2));

        [self addChild:ground];

        /* STICKMAN */

        SKTextureAtlas *stickmanTextureAtlas = [SKTextureAtlas atlasNamed:@"Stickman"];

        stickmanFrames = @[[stickmanTextureAtlas textureNamed:@"stickman1"],
                           [stickmanTextureAtlas textureNamed:@"stickman2"]];

        stickmanSprite = [SKSpriteNode spriteNodeWithTexture:stickmanFrames[0]];

        CGPoint stickmanPosition = CGPointMake(200, 100);
        stickmanSprite.position = stickmanPosition;

        [self addChild:stickmanSprite];

        [stickmanSprite runAction:[SKAction repeatActionForever:
                         [SKAction animateWithTextures:stickmanFrames
                                       timePerFrame:0.5f
                                             resize:NO
                                            restore:YES]] withKey:@"walkingInPlaceStickman"];

    }
    return self;
}

为什么会这样?即使没有使用其CGSize缩放图像,这仍然会发生。图像的实际大小(以像素为单位)相同。

0 个答案:

没有答案