Serious SpriteKit UIColor bug on iPhone 5S

I found a serious quick bug in SpriteKit while working with SKSpriteNodes and their colors.

This code works fine on all iPhone 5s:

var color1 = UIColor(red: 123/255, green: 123/255, blue: 123/255, alpha: 1)
var color2 = UIColor(red: 123/255, green: 123/255, blue: 123/255, alpha: 1)

var sprite = SKSpriteNode(color: color1, size: CGSizeMake(100, 100))

if(sprite.color == color2){
     println("Same color")
}

As you can see, these two colors are absolute. But on the iPhone 5S simulator, if not called.

Does anyone have another problem and can provide a solution?

0
source share
2 answers

According to the documentation here :

Sprite Kit . , , RGBA.

- SKSpriteNode color init. , encode:

sprite.color.encode() // 140,646,370,382,768

color1.encode() // 140,646,367,110,928

, :

var color3 = UIColor.blueColor()
var sprite3 = SKSpriteNode(color: color3, size: CGSizeMake(100, 100))

sprite3.color == color3 // true
0

, . , UIColor, isEqual ( ObjC, , Swift - , , Swift isEqual ):

if ([sprite.color isEqual:color2])

UIColor, , .

0

Source: https://habr.com/ru/post/1622265/


All Articles