첫 번째 스프라이트, 다람쥐 및 두 번째 스프라이트 인 도토리/너트가 충돌 한 후 GameOverScene을 사용하려고합니다. 지금은 두 스프라이트가 충돌 할 때 다람쥐가 화면에서 떨어집니다. 다람쥐가 화면에서 떨어지지만 끝 화면이 나타나길 바래. 나는이 말을하고이 페이지에서 시작 화면에 대한 자습서를 사용하여 시도충돌 감지 후 끝 화면 표시
- (instancetype)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
self.physicsWorld.contactDelegate = self;
[self buildBackground];
[self startScrolling];
[self initializeStartGameLayer];
[self initializeGameOverLayer];
_firstPosition = CGPointMake(self.frame.size.width * 0.817f, self.frame.size.height * .40f);
_squirrelSprite = [SKSpriteNode spriteNodeWithImageNamed:@"squirrel"];
_squirrelSprite.position = _firstPosition;
_atFirstPosition = YES;
_squirrelSprite.physicsBody = [SKPhysicsBody bodyWithCircleOfRadius:10];
_squirrelSprite.physicsBody.categoryBitMask = squirrelHitCategory;
_squirrelSprite.physicsBody.contactTestBitMask = nutHitCategory;
_squirrelSprite.physicsBody.collisionBitMask = nutHitCategory;
_squirrelSprite.physicsBody.affectedByGravity = NO;
self.physicsWorld.contactDelegate = self;
[self addChild:_squirrelSprite];
SKAction *wait = [SKAction waitForDuration:3.0];
SKAction *createSpriteBlock = [SKAction runBlock:^{
SKSpriteNode *lightnut = [SKSpriteNode spriteNodeWithImageNamed:@"lightnut.png"];
BOOL heads = arc4random_uniform(100) < 50;
lightnut.position = (heads)? CGPointMake(257,600) : CGPointMake(50,600);
lightnut.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:CGSizeMake(200,160)];
lightnut.physicsBody.categoryBitMask = nutHitCategory;
lightnut.physicsBody.contactTestBitMask = squirrelHitCategory;
lightnut.physicsBody.collisionBitMask = squirrelHitCategory;
lightnut.physicsBody.affectedByGravity = NO;
self.physicsWorld.contactDelegate = self;
[self addChild: lightnut];
SKAction *moveNodeUp = [SKAction moveByX:0.0 y:-700.0 duration:1.3];
[lightnut runAction: moveNodeUp];
}];
SKAction *waitThenRunBlock = [SKAction sequence:@[wait,createSpriteBlock]];
[self runAction:[SKAction repeatActionForever:waitThenRunBlock]];
}
return self;
}
: http://mytechspace.com/2014/02/tutorial-how-to-develop-flappy-bird-game-in-ios-using-spritekit-part2-of-2.html을하지만 둘 다 내 시작 또는 끝 화면이 나타나지 않았다 (나는 무엇인지 모르겠어요 여기에 지금까지 무엇을 가지고 그것을 멈추게한다).
-(void)didBeginContact:(SKPhysicsContact *)contact
{
SKPhysicsBody *firstBody, *secondBody;
firstBody = contact.bodyA;
secondBody = contact.bodyB;
if(firstBody.categoryBitMask == squirrelHitCategory || secondBody.categoryBitMask == nutHitCategory)
{
}
감사합니다 :
여기에 내 연락처 위임 방법입니다!
연락처 위임 방법 (예 : -didBeginContact :)도 게시하시기 바랍니다. – ZeMoon
감사합니다. – Ryandev
중복 https://stackoverflow.com/questions/26764620/start-screen-and-end-screen-after-collision-detection/26767436#26767436 – meisenman