IOS SpriteKit Get all the nodes in the current scene and make the application universal.

Hi, I am new to sprite creation. I just wanted to know two things:


1) How to get all SKSprite nodes in the current scene?
2) How to make the application universal, that is, it will work on iPhone 3.5 ", iPhone 4" and iPad?


Thanks in advance.

+4
source share
2 answers
+4
source

, , , , , . , , , , , :

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];
0

Source: https://habr.com/ru/post/1532406/


All Articles