来自spritekit的png的物理身体

时间:2015-01-15 23:20:56

标签: sprite-kit

我想从.png文件中创建一个物理实体。 有些pic可以使用,有些则不行。但都有alpha通道..

我的代码有问题吗?

SKTexture *shapeTex = [SKTexture textureWithImage:[UIImage imageNamed:@"shapes"]];
SKSpriteNode *shape = [SKSpriteNode spriteNodeWithTexture:shapeTex];
shape.physicsBody = [SKPhysicsBody bodyWithTexture:shapeTex size:shapeTex.size];
shape.physicsBody.dynamic = 0;
shape.physicsBody.usesPreciseCollisionDetection = 1;
shape.position = CGPointMake(size.width/2, size.height/2);
shape.physicsBody.friction = 0.1;
shape.size = self.size;
[self addChild:shape];

0 个答案:

没有答案