gpt4 book ai didi

ios - 如何在没有抗锯齿的情况下缩放 SKSpriteNode

转载 作者:技术小花猫 更新时间:2023-10-29 10:45:07 27 4
gpt4 key购买 nike

我试图在没有平滑/抗锯齿的情况下缩放 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 enter image description here .

最佳答案

尝试,

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com