【问题标题】:How to pass parameters with replaceScene method in cocos2d?cocos2d中如何用replaceScene方法传递参数?
【发布时间】:2013-01-03 16:01:16
【问题描述】:

当我在 Cocoa Touch 中更改视图时,我使用这个:

GameViewController *game = [self.storyboard instantiateViewControllerWithIdentifier:@"GameViewController"];
game.something = someValue;
game.somethingOther = someOtherValue;

[self presentViewController:game animated:NO completion:^{}];

如何在replaceScene 之前传递这些值?

我现在有这个:

[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1.0 scene:[GameLayer scene] withColor:ccWHITE]];

【问题讨论】:

    标签: objective-c view properties cocos2d-iphone scene


    【解决方案1】:

    好的,这很容易......

    需要创建方法+(CSScene *)sceneWithParameter: 和方法-(id)initWithParameter:。并且在第一种方法中需要在ClassLayer *layer = [[ClassLayer alloc] initWithParameter:] 上更改ClassLayer *layer = [ClassLayer node] 并且它可以工作。

    【讨论】:

      猜你喜欢
      • 2014-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-15
      相关资源
      最近更新 更多