2016-01-11 25 views
0

我目前正試圖在雪碧套件中放置一個測試遊戲。我有一些代碼,使用尺寸爲200 * 572的一對PNG圖像創建一個地面片。如何關閉精靈套件節點的紋理上的抗鋸齒

let textures = [SKTexture(imageNamed: "GrassAni1"), SKTexture(imageNamed: "GrassAni2")] 

for (var i = 0; i < 10; i += 1) { 
    let chunk = SKSpriteNode(texture: textures[0]) 
    chunk.position = CGPointMake(CGFloat(200 * i), 0) 
    let animate = SKAction.animateWithTextures(textures, timePerFrame: 1) 
    chunk.runAction(SKAction.repeatActionForever(animate)) 
    //boilerplate physics body code… 
    self.addChild(hero) 
} 

輸入我的問題。這是在Xcode文件瀏覽器我的精靈的近距離:enter image description here

,這裏是什麼樣子,當遊戲運行:enter image description here 遊戲中的精靈似乎是反走樣,因此長相模糊。我如何防止這種情況發生,並使遊戲看起來像原始圖像一樣清晰?

回答

4

您需要將您的SKTexture對象上的filteringMode更改爲SKTextureFilteringMode.Nearest

然後只要您的節點位於像素邊界,它應該按預期繪製。