SORU
29 EYLÜL 2013, Pazar


SKScene düğmeleri ayarlama

UIButtons SKNode SpriteKit bir düğme yapmak için alt getiriyorum çok iyi SKScene ile çalışmıyor fark ettim.

Ben böyle olacağını bir iş ise başlatma düğmesi SKScene ve etkinleştirmek dokunma olayları, sonra düğmeyi Ara bir yöntem benim SKScene zaman bastırdı.

Bu soruna çözüm bulmak için bana yol açacak herhangi bir tavsiye takdir ediyorum. Teşekkürler.

CEVAP
29 EYLÜL 2013, Pazar


düğme gibi bir SKSpriteNode kullanabilirsiniz, ve sonra kullanıcı dokunduğunda, eğer bu düğüm dokundu olmadığını kontrol edin. Bu SKSpriteNode adı özelliği düğümü tanımlamak için kullanın:

//fire button
- (SKSpriteNode *)fireButtonNode
{
    SKSpriteNode *fireNode = [SKSpriteNode spriteNodeWithImageNamed:@"fireButton.png"];
    fireNode.position = CGPointMake(fireButtonX,fireButtonY);
    fireNode.name = @"fireButtonNode";//how the node is identified later
    fireNode.zPosition = 1.0;
    return fireNode;
}

Sahne için düğüm ekleyin:

[self addChild: [self fireButtonNode]];

Dokunduğu kolu:

//handle touch events
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInNode:self];
    SKNode *node = [self nodeAtPoint:location];

    //if fire button touched, bring the rain
    if ([node.name isEqualToString:@"fireButtonNode"]) {
         //do whatever...
    }
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Arun Kumar

    Arun Kumar

    18 Mart 2010
  • Elly Awesome

    Elly Awesome

    15 ŞUBAT 2010
  • ImBluecams

    ImBluecams

    25 Kasım 2012