SKSpriteNode * test = [[SKSpriteNode alloc] initWithColor:[UIColor redColor] size:CGSizeMake(100, 100)];
[self addChild:test];
[test setPosition:CGPointMake(300, 300)];
// bottom
CGSize textureSize = CGSizeMake(100, 100);
SKPhysicsBody *physicsBottom = [SKPhysicsBody bodyWithRectangleOfSize:textureSize];
physicsBottom.categoryBitMask = ColliderBottom;
physicsBottom.contactTestBitMask = ColliderBottom | ColliderObstacle;
// working...
// test.physicsBody = physicsBottom;
// not working... this line is problem.
test.physicsBody = [SKPhysicsBody bodyWithBodies:@[physicsBottom]];
didEndContact未能通过此代码工作。ios sprite kit bodyWithBody not working
test.physicsBody = [SKPhysicsBody bodyWithBodies:@[physicsBottom]];
什么问题????
typedef enum {
ColliderObstacle = 1 << 0,
ColliderCharacter = 1 << 2,
ColliderLeft = 1 << 3,
ColliderRight = 1 << 4,
ColliderBottom = 1 << 5,}ColliderType;
//没有开口......这条线......我不明白。 为什么EndContact事件不起作用???????
我无法看到任何地方如何创建physicsComponentBottom.physicsBody(有physicsBottom节点,但我想这是另一个节点) – Whirlwind
更改我的代码为简单。 –