ios – 如何在没有抗锯齿的情况下缩放SKSpirteNode

前端之家收集整理的这篇文章主要介绍了ios – 如何在没有抗锯齿的情况下缩放SKSpirteNode前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试扩展一个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
原文链接:https://www.f2er.com/iOS/329483.html

猜你在找的iOS相关文章