我正在尝试扩展一个SKSpriteNode对象,没有平滑/反锯齿(我使用像素艺术,所以它看起来更好的像素化).
有没有一个财产我需要设置这样做?这是我用来渲染精灵的代码:
SKTextureAtlas *atlas = [SKTextureAtlas atlasNamed:@"objects"]; SKTexture *f1 = [atlas textureNamed:@"hero_1.png"]; SKSpriteNode *hero = [SKSpriteNode spriteNodeWithTexture:f1]; [self addChild: hero]; hero.scale = 6.0f;
图像缩放正确,但模糊/平滑.这是hero_1.png.
解决方法
尝试,
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.
迅速:
sprite.texture!.filteringMode = .Nearest