为什么我无法使用SKPhysicsBody构造函数?

时间:2015-01-26 07:12:08

标签: swift ios8 sprite-kit skphysicsbody sktexture

我正在使用swrite的spritekit(ios8,xcode 6)。当我使用physicsbody构造函数self.physicsBody = SKPhysicsBody(texture: myTexture, size: myTexture.size())时,它每次都会失败,并出现以下错误:

<Error>: CGBitmapContextCreate: unsupported parameter combination:
 8 integer bits/component; 32 bits/pixel; 
 3-component color space;
 kCGImageAlphaPremultipliedLast; 127 bytes/row.   

然而,当我切换回像'SKPhysicsBody(rectangleOfSize:...)'这样的物理体构造函数时,它工作得很好......但是我想使用基于纹理的物理体。为什么会发生此错误以及如何解决?

1 个答案:

答案 0 :(得分:0)

我通过简化我用来生成物理体的纹理的形状来解决这个问题。我怀疑使用具有某些特征的形状(我没有花时间来识别)产生物理体存在问题。无论如何,SpriteKit中肯定存在一个错误,或者至少返回的错误消息没有传达有关错误发生原因的相关信息。顺便说一句,更改每个通道的位数没有任何影响。

所以,如果可以的话,我会尝试简化你的形状。在我的情况下,此图像:Sprite that generates error在用于初始化PhysicsBody时生成错误,而此图像:Sprite that does not generate an error则不会。

相关问题