Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS SpriteKit获取当前场景中的所有节点,并使应用程序具有通用性。_Ios_Iphone_Sprite Kit - Fatal编程技术网

iOS SpriteKit获取当前场景中的所有节点,并使应用程序具有通用性。

iOS SpriteKit获取当前场景中的所有节点,并使应用程序具有通用性。,ios,iphone,sprite-kit,Ios,Iphone,Sprite Kit,您好,我是sprite kit framework的新手,我只想知道两件事: 1)如何获取当前场景中的所有SKSprite节点 2)如何使该应用程序具有通用性,即它将在iPhone 3.5、iPhone 4和iPad上运行 提前谢谢 在Scene.m中,您可以使用self.children获取所有SKSprite节点 虽然你的答案的第二部分太宽泛了,但我能理解你是从哪里来的,因为试图弄明白如何支持所有不同的屏幕尺寸有点困难。但对于其他遇到类似过于宽泛的问题的新开发人员,如果您只是想让场景适

您好,我是sprite kit framework的新手,我只想知道两件事:


1)如何获取当前场景中的所有SKSprite节点
2)如何使该应用程序具有通用性,即它将在iPhone 3.5、iPhone 4和iPad上运行


提前谢谢

  • 在Scene.m中,您可以使用
    self.children
    获取所有SKSprite节点

  • 虽然你的答案的第二部分太宽泛了,但我能理解你是从哪里来的,因为试图弄明白如何支持所有不同的屏幕尺寸有点困难。但对于其他遇到类似过于宽泛的问题的新开发人员,如果您只是想让场景适应不同的屏幕分辨率,并且暂时想忽略多个图像分辨率和资源目录的概念,那么首先要处理场景的大小及其缩放模式:

    在viewController中,可以执行以下操作。它有点笨手笨脚,但设计的目的是为了显示区别:

    //we'll set what we want the actual resolution of our app to be (in points)
    //remember that points are not pixels, necessarily
    CGSize sceneSize = CGSizeMake(320, 568);
    
    //check if this is an ipad, this means the screen has 2x the points
    //it also means that the resolution is different than the iphone 5
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        sceneSize = CGSizeMake(sceneSize.width * 2, sceneSize.height * 2);
    }
    
    
    SKView *skView = (SKView*)self.view;
    self.mainPrimaryScene = [[PrimaryScene alloc] initWithSize: sceneSize forSKView:skView];
    
    //by setting the scale mode to fit, it takes the size of the scene
    //and ensures that the entire scene is rendered on screen, in the correct ratio
    self.mainPrimaryScene.scaleMode = SKSceneScaleModeAspectFit;
    
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
    //you can check out all the other scale modes if you want to fill, etc
        mainPrimaryScene.scaleMode = SKSceneScaleModeResizeFill;
    
    }
    
    [skView presentScene:mainPrimaryScene];
    

    你对1的回答。似乎没有真正回答这个问题,是吗?场景的子节点可以再次拥有子节点,因此self.children不会提供场景中所有节点的完整列表,而只提供场景的子节点的完整列表。。。。