作者热门文章
- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我试图在没有平滑/抗锯齿的情况下缩放 SKSpriteNode 对象(我使用的是像素艺术,因此像素化效果更好)。
我需要设置一个属性来执行此操作吗?这是我用来渲染 Sprite 的代码:
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.
swift :
sprite.texture!.filteringMode = .Nearest
关于ios - 如何在没有抗锯齿的情况下缩放 SKSpriteNode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19193005/
我是一名优秀的程序员,十分优秀!