【发布时间】:2015-10-05 11:08:28
【问题描述】:
我正在尝试检查 bodyAA 的纹理是否命名为“playerpc”。如果是,我想运行一个动作,但我不知道如何检查。
我现在使用的代码:
var testnode = SKSpriteNode(imageNamed: "playerpc")
print(testnode.texture)
if bodyAA.texture == testnode.texture{
print("Yes the same")
}
else{
print(bodyAA.texture)
}
这是控制台的结果:
Optional(<SKTexture> 'playerpc' (153 x 274))
Optional(<SKTexture> 'playerpc' (153 x 274))
所以应该是一样的!但是当它比较时,我的代码决定它不一样,我该如何解决这个问题?
【问题讨论】:
-
因为你必须指出你在纹理中比较的是什么,因为它有它自己的属性。
标签: ios swift comparison textures sktexture