很抱歉新手问题,但我想知道这两个场景的不同设置之间的区别是什么?这层?我尝试了两种方式,每种方式都有效,但我不知道区别是什么,或者我应该使用哪种方式。
@implementation Game
+(id) scene {
CCScene *scene = [CCScene node];
[scene addChild:[Game node]];
return scene; }
或者这样。
@implementation Game
+(id) scene {
CCScene *scene = [CCScene node];
Game *layer = [Game node];
[scene addChild:layer];
return scene; }
答案 0 :(得分:1)
我认为您的2个代码示例之间没有任何区别。你的两种方法完全相同。
[Game node]
返回一个图层,因此在第一种情况下,您将其直接添加到场景中,在第二个示例中,您只需将其添加到变量中,然后将其添加到场景中。
对于编译器来说,这是相同的事情。