【问题标题】:How to add a Get Ready screen in spritekit如何在 spritekit 中添加准备就绪屏幕
【发布时间】:2014-03-18 02:19:59
【问题描述】:

您好,我想添加一个标题或标签,上面写着“准备就绪”,当您点击它时,您会开始生成自定义精灵。有谁知道如何做到这一点。作为参考,我希望“准备就绪”屏幕表现得像 Flappy Birds 或 Splashy Fish。我可以从哪里获得这方面的信息?

【问题讨论】:

    标签: ios iphone sprite-kit


    【解决方案1】:
    SKSpriteNode *getReady = [SKSpriteNode spriteNodeWithImageNamed:@"myImage.png"];
    //remember to set position and other custom stuff here
    [self addChild:getReady];
    _isFirst = YES; //BOOL property 
    
    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        if (_isFirst)
        {
            SKAction *fadeOut = [SKAction fadeOutWithDuration:10];
            [getReady runAction:fadeOut];
            _isFirst = NO;
        } else {
            //other time you tap, code here
        }
    }
    

    【讨论】:

      【解决方案2】:

      您需要使用您想要的图像创建一个 SKSpriteNode 并将其添加到您的场景中。

      SKSpriteNode *getReady = [SKSpriteNode spriteNodeWithImageNamed:@"myImage.png"];
      //remember to set position and other custom stuff here
      [self addChild:getReady];
      

      然后当用户点击时,你可以运行一个动作来淡出它。

      -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
      {
          SKAction *fadeOut = [SKAction fadeOutWithDuration:10];
          [getReady runAction:fadeOut];
      }
      

      另外,如果您查看一些教程,我认为您会很棒,因为那是非常基本的东西。我相信你可以很容易地找到。

      【讨论】:

      • 你应该在 touchesBegan: 方法中添加 if/else,因为第一次你淡出 getReady 和其他时候你玩游戏。
      • 是的,这将是一个更复杂的代码,但它不是强制性的。唯一的区别在于性能相关。
      猜你喜欢
      • 2012-02-15
      • 1970-01-01
      • 1970-01-01
      • 2019-10-09
      • 2017-07-05
      • 1970-01-01
      • 2022-10-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多