`SKView *skView = (SKView *) self.view;
SKScene *scene = [MyScene sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
[skView presentScene:scene];`
So MyScene is the homepage which you present when you start the game. After picking a map and failing at the game, if you press the button to go back to the homepage and go to get right back into the maps section of the game The map I clicked gets loaded into the view randomly. Any help would be great, I'm not getting an error because its just loading into the view and starts the game.
Okay here is the code from the homepage scene that sends you to the sections screen
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
//Called when a touch begins
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];
if([node.name isEqualToString:@"playButton"])
{
SKView *skView = (SKView *) self.view;
SKScene *scene = [SectionsScreen sceneWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
[skView presentScene:scene];
}
}
Then Once you pick the first section you transition to the viewcontroller with all of the maps loaded into it.
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInNode:self];
SKNode *node = [self nodeAtPoint:location];
node.xScale = 1;
node.yScale = 1;
for (SKSpriteNode *label in self.sectionNumAra)
{
if([[@"section" stringByAppendingString:label.name] isEqualToString:node.name])
{
label.xScale = 1;
label.yScale = 1;
}
}
if([node.name isEqualToString:@"section1"])
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"closeScene" object:nil];
MainViewController *main = [[MainViewController alloc]init];
UIViewController *vc = self.view.window.rootViewController;
[vc presentViewController: main animated: YES completion:nil];
}
This is the transition into that.
After picking a map transition to the skscene here
SKView *skView = (SKView *) self.view;
SKScene *scene = nil;
//Continue to make if statements to open the correct map.
if([[GameData sharedGameData].mapChosen isEqualToString:@"FirstMap"])
{
scene = [FirstMap sceneWithSize:skView.bounds.size];
}
scene.scaleMode = SKSceneScaleModeAspectFill;
[skView presentScene:scene];
Everything works great so far... Now once the "game ended alert pops up if you choose to go back to the Sections Screen (which is an scene) you may go back there. But after clicking on a section you are not allowed to go into. I get the previous map or previous view controller loaded right onto that scene.