How do you scale SKSpirteNode without anti aliasing

后端 未结 3 1368
北荒
北荒 2021-02-08 02:18

I am trying to scale an SKSpriteNode object without smoothing/anti-aliasing (I\'m using pixel-art so it looks better pixelated).

Is there a property I need to set to do

相关标签:
3条回答
  • 2021-02-08 03:07

    try this:

    hero.xscale = 6.0f;
    hero.yscale = 6.0f;
    
    0 讨论(0)
  • 2021-02-08 03:09

    Try,

    SKTexture *texture = [SKTexture textureWithImageNamed:@"Fak4o"];
    texture.filteringMode = SKTextureFilteringNearest;
    SKSpriteNode *newHero = [SKSpriteNode spriteNodeWithTexture:texture];
    newHero.position = CGPointMake(200, 200);
    [newHero setScale:50];
    [self addChild:newHero];
    

    SKTextureFilteringNearest

    Each pixel is drawn using the nearest point in the texture. This mode is faster, but the results are often pixelated.

    Swift:

    sprite.texture!.filteringMode = .Nearest
    
    0 讨论(0)
  • 2021-02-08 03:18

    Just a note, if you create a SKSpriteNode instead of SKTexture, you can set the SKTextureFilteringNearest like in the following example:

    SKSpriteNode *asteroid = [SKSpriteNode spriteNodeWithImageNamed:@"o1"];
    asteroid.size = CGSizeMake(36, 24);
    asteroid.position = CGPointMake(startX, startY);
    asteroid.name = @"obstacle";
    // >>>
    asteroid.texture.filteringMode = SKTextureFilteringNearest;
    // <<<
    [self addChild:asteroid];
    
    0 讨论(0)
提交回复
热议问题