iOS 7 SpriteKit - Creating game menus/buttons (Scenes vs. more view controllers)

前端 未结 3 686
暗喜
暗喜 2021-02-03 10:06

So, I\'ve begun working on a project in SpriteKit, and I\'m hoping to be able to implement a \"main menu\" scene with a few buttons. One would go to a level select screen, one w

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-03 10:57

    if you want a simple menu you can create it with SpriteKit but if you want a complex menu you should use UIKit.

    Let's say that you want to create a level selection menu with CoverFlow effect, that will be hard to implement from scratch on SpriteKit but for UIKit you can find libraries like iCarousel that implements stunning CoverFlow and scroll effects with ease.

    SKLabelNode by the moment only supports one text line so if you want to add a really long message in your game that will be difficult but if you use UIKit instead you can use a UITextView to display your long message.

    a detailed In App Purchases menu will be easier to create with UIKit.

    UIKit will avoid you a lot of headache, i really encourage you to use it.

    how should the project be set up?

    You only need 1 Scene

    MenuviewController->( Push Segue )->LevelSelectionController->( Push Segue )->GameScene

    I suppose I'd want them to float around or get bigger when selected (when the user has touched it but not let go), and I believe that a UIButton would not allow it since it isn't an SKSpriteNode.

    you can add animations to a UIButton with UIView animateWithDuration or CABasicAnimation

    That would mean that I would have to set buttons to be hidden on every new scene displayed

    Solve it with a function

    - (void)setHidden:(BOOL)hide {
        UIButton *tmpButton = (UIButton *)[self.view viewWithTag:100];
        tmpButton.hidden = hide ? YES : NO;
    }
    

    Hide it like this

    [self setHidden:YES];
    

    Hope it helps

    Good Luck!

提交回复
热议问题