如何在没有抗锯齿的情况下缩放SKSpirteNode [英] How do you scale SKSpirteNode without anti aliasing

查看:86
本文介绍了如何在没有抗锯齿的情况下缩放SKSpirteNode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试缩放SKSpriteNode对象而不进行平滑/消除锯齿(我使用像素艺术,因此它看起来更像像素化)。

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 this? This is the code I am using to render the 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 。

The image is scaled correctly but blurry/smoothed out. This is 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

这篇关于如何在没有抗锯齿的情况下缩放SKSpirteNode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆