Ok, So it’s time to wrap up this series. Today I will be showing you how to add a few “bells and whistles” that will make your game more complete. Let’s start by adding a splash screen to your game (Again I truly apologize for the lack of graphics skillz. Photoshop and I are not friends).
Creating a Splash Page
We will be adding a splash page that will fade out into our main game screen. Start by downloading this image and adding it to your project’s Resources Folder. Make sure you check the box to copy this image to the project’s directory.
Now we need to add a View Controller to our project that will handle the Splash View. Go ahead and add a new file to your project that is a UIViewController subclass. Name this file SplashViewController. Make sure you check to create the .h file as well.
Advertisement
Next, we need to change our AppDelegate to load this view controller instead of our main view controller. Open up iTennisAppDelegate.h and change it to look like this:
We are basically replacing iTennisViewController with SplashViewController. Next, open up iTennisAppDelegate.m and change it to look like this:
Again, all we are really doing is changeing iTennisViewController with SplashViewController. This is because we want to load the splash page initially and not the main game screen. One main difference to note here is we are allocating a new instance of the SplashViewController. We didn’t have to do that with the iTennisViewController because it was being loaded from a nib and our application initialized it for us. Since we are building SplashViewController programatically (without a nib), we need to instantiate it. Next, let’s implement the Splash View. Open up SplashViewController.h and add the following code:
Let me explain what’s going on here. First, we see an NSTimer. This will be used to display the splash page for a certain amount of time before fading to our main game screen. Next, there is a UIImageView. This will simply be the imageview of our splash image.
Finally, we see the iTennisViewController. This is the view controller that we replaced inside of our application’s delegate. We will be loading it from our splash view. Now, open up SplashViewController.m and add the following code:
This is just synthesizing all of our properties. Now, add the following code to our loadView method:
Lot’s of new code here. First off, since we are loading this view programatically without a nib, we have to create the view. So we get the frame that the application is running in and use it to allocate a new view. Then we set the view of the SplashViewController to this newly created view. We have to create the frame to basically tell the application to create a view that is 320×480.
The next thing we do is create the splashImageView from the Splash.png image. We also need to create a frame for this images. Think of a frame as an empty container that we will put our image in. Next we add the imageview to our main view. This will display it immediately.
Next, we initialize our view main controller by passing it the nib it will load from. Next, the view’s alpha transparency is set to 0.0. This makes it completely invisible. Finally, we add it to our view. Note that it is on top of the splashimageview but is not visible because the alpha transparency is set to 0.0.
Finally, we start the timer. This will show the splash screen for 2 seconds before calling the “fadeScreen” method. Let’s implement the fadescreen method. I must note that I took the fadescreen method from this post.
Add the following code:
Lots of animation stuff. Pretty well commented so I wont go into it too much. Basically, we fade the view out in fadeScreen, then it calls finishedFading when its done. Finished fading fades the view back in as well as fades viewController’s view back in. It will now display our main view. Make sure you remove the splash from the superview or you will get a weird transition.
That’s it for the splash page. You can Build and Go to see the view transition from a splash to the main game.
That’s all for today. Join me next time when I will show you how to add audio to your game. If you have any questions or comments, feel free to leave them in the comments section or write me on Twitter.
You can download the source for this tutorial here
These are great tutorials! I was going to go farther in depth to them by figuring out the code lol, but ever since the website move a lot of the images in the newer tutorials are gone, so you might want to upload them again..
Thank You for all the time and work you put into all these tutorials to help newbies like me =D
How should the source code be if i don’t want a fader to go from the splash screen to the mainscreen? I want to tap the splash screen to go to the mainscreen.
Занятно пишете, жизненно. Все-таки, для того, чтобы делать по-настоящему интересный блог, нужно не только сообщать о чем-то, но и делать это в интересной форме:)
I am not able to get the project to launch in the build and run, as soon as the splash screen launches it crashes, I have gone back over all of the tutorials and everything is correct, I have even downloaded your source code and it does the same thing as well i don’t know if I am doing something wrong but I cannot get the product to launch.
Make sure and review the use of capital letters. Look at your code and make sure the color of the words match the example. If not there is an error, you might need to retype that section.
You don’t need to do all this just for a splash screen. You can just post in your Default.png into Xcode, and then in the ApplicationDidFinishLaunching; method, you would put [sleep 5] (to sleep 5 seconds). During this sleep period, Default.png is shown.
Of course, if you wanted it to fade out, then your method is better, but for a basic splash screen, you only need one line of code.
Hello,
I try to understand this tutorial and there is something i don’t understand…
When we open the application, we can see a first image which name is “Defaut.png”.
After, we can see the splash screen.
But, where is declare this image “Defaut.png” ??
Can you use the same principle for a Game start screen, where when you first run the application it says a variant of “Start game”, “Continue Game”, “Hi-scores”, “Credits”, etc?
Ich kann die Source-Dateien nicht “builden”.
Fehlermeldung: error: There is no SDK with the name or path ‘iphoneos2.2′
Sollte das Zeug nicht in soweit abwärtskompatibel sein?
Wie kann ich das beheben (Es wird mir nicht angezeigt, welche Datei genau für den Ärger verantwortlich ist)?
Ansonsten: Nettes Tut!
Sh**! I’d had to write in English!
So: I’m not able to build the source data. I always get this error: There is no SDK with the name or path ‘iphoneos2.2′
Does the newest version of XCode not support this code or what?
How can I fix this because XCode doesn’t tell me in which part of the program the error is located.
But this is a very good tutorial!
———————————————–
Sorry for my bad English.
[...] Cocos2d-iPhone Collection of various links Homepage Google group API reference Notes on Cocos2d iPhone Development Move sprite example Introduction to Cocos2d iPhone Monocles Studio Intro Collision particle Great site with lots of simple examples Game walkthrough Sapus Tongue Sources Coloring Sprites Bounching ball 2 Permadi Splash screen [...]
[...] = ‘brandontreb’; It’s been a while, but I finally posted part 3 of the iPhone Game Programming tutorial series on iCodeblog.com. The focus of this tutorial was to create a splash page for your game [...]
[...] “Bubi Devs”. La versione originale inglese del tutorial è disponibile a questo indirizzo: “iPhone Game Programming Tutorial, Part 2 – iCodBlog“. I meriti quindi relativamente alla versione inglese, sono del legittimo [...]
[...] a time. Ok, let’s get started… Make sure you are starting with the base code from the previous tutorial (either use yours or download a fresh copy). We will be using 2 sounds today, 1 for when the ball [...]
[...] a time. Ok, let’s get started… Make sure you are starting with the base code from the previous tutorial (either use yours or download a fresh copy). We will be using 2 sounds today, 1 for when the ball [...]
93 Comments
These are great tutorials! I was going to go farther in depth to them by figuring out the code lol, but ever since the website move a lot of the images in the newer tutorials are gone, so you might want to upload them again..
Thank You for all the time and work you put into all these tutorials to help newbies like me =D
Techy
How should the source code be if i don’t want a fader to go from the splash screen to the mainscreen? I want to tap the splash screen to go to the mainscreen.
Thanks for putting the time into these great tutorials!
tnndxqocdcku
По правде говоря, сначала не очень то до конца понял, но перечитав второй раз дошло – спасибо!
respect
Спасибо! Пригодится…..
Занятно пишете, жизненно. Все-таки, для того, чтобы делать по-настоящему интересный блог, нужно не только сообщать о чем-то, но и делать это в интересной форме:)
Чем-то это отдает напеванием свирели в предновогоднюю ночь, чем то похоже на праздникк, чем-то на казино… Ну сами продолжите дальше
The court should try to determine beforehand, as best it can, if the victim is subject to battered women’s syndrome. ,
Hi Brandon,i tried using this
- (void)loadView
{
// Init the view
CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
UIView *view = [[UIView alloc] initWithFrame:appFrame];
view.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
self.view = view;
[view release];
logoImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo.jpg"]];
logoImageView.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:logoImageView];
splashImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"splash.jpg"]];
splashImageView.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:splashImageView];
ballImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"menu.jpg"]];
ballImageView.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:ballImageView];
viewController = [[Nine_WarriorsViewController alloc] initWithNibName:nil bundle:[NSBundle mainBundle]];
viewController.view.alpha = 0.0;
[self.view addSubview:viewController.view];
splashCounter =0;
timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(fadeScreen) userInfo:nil repeats:YES];
}
as i am trying to show logo ,splash and then menu page but this is working fine but i am trying to do following in
- (void) finishedFading
{
splashCounter++;
[UIView beginAnimations:nil context:nil]; // begins animation block
[UIView setAnimationDuration:0.75]; // sets animation duration
self.view.alpha = 1.0; // fades the view to 1.0 alpha over 0.75 seconds
viewController.view.alpha = 1.0;
[UIView commitAnimations]; // commits the animation block. This Block is done.
if(splashCounter == 1)
{
[logoImageView removeFromSuperview];
}
else if(splashCounter == 2)
{
[splashImageView removeFromSuperview];
}
else if(splashCounter == 3)
{
[ballImageView removeFromSuperview];
[timer invalidate];
}
//[timer setFireDate:[NSDate dateWithTimeIntervalSinceNow:1]];
//timer1 = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(fadeScreen) userInfo:nil repeats:NO];
}
but the above method is not working properly as its suppose to delete logo image then splash and then should show menu image
but it keeps showing menu image all the times with fading effect…..where am i doing wrong??? please help
ohh i got it….its my silly mistake…. i was drawing it other way around….its solved…
How do i make the first and second image the same amount of seconds of showing?
Mine doesn’t open properly please help
for some reason my pics disappear according to alert Help???!!!
Thank you very, very, very much for taking the time to post these tutorials, they are a great help.
I’m getting this error:
iTennisAppDelegate.m:18: error: ‘SplashViewController’ undeclared (first use in this function)
Help?
I am not able to get the project to launch in the build and run, as soon as the splash screen launches it crashes, I have gone back over all of the tutorials and everything is correct, I have even downloaded your source code and it does the same thing as well i don’t know if I am doing something wrong but I cannot get the product to launch.
Make sure and review the use of capital letters. Look at your code and make sure the color of the words match the example. If not there is an error, you might need to retype that section.
модернизация компьютера
You don’t need to do all this just for a splash screen. You can just post in your Default.png into Xcode, and then in the ApplicationDidFinishLaunching; method, you would put [sleep 5] (to sleep 5 seconds). During this sleep period, Default.png is shown.
Of course, if you wanted it to fade out, then your method is better, but for a basic splash screen, you only need one line of code.
Купить виниловые пластинки
Ингаляторы
SEO
русские люди
Скачать java игры
parkour
В рот мне ноги, глупая новость
Автор неутомим
Не поспоришь, веселая новость
Честное слово, неуместная заметка
рецепты с фотографиями
Не спорю, получилась статья
Чего и следовало ожидать, написавший кошерно накропал.
Черт, плохая статья
Должен признать, афтар ништяк опубликовал!
Hello,
I try to understand this tutorial and there is something i don’t understand…
When we open the application, we can see a first image which name is “Defaut.png”.
After, we can see the splash screen.
But, where is declare this image “Defaut.png” ??
Супер! Спасибо :0
hello,
Your tutorials are really Best. I was given to build a game in iphone and didn’t even know objective-c but your tutorials proved best guide for me.
Thank you so much !!! Please keep adding such tutorials, these will help all the people who are new to iphone like me and also to others.
Can you use the same principle for a Game start screen, where when you first run the application it says a variant of “Start game”, “Continue Game”, “Hi-scores”, “Credits”, etc?
Thanks
Very great tutorial, I am very grateful for your hardwork and good intentions. tyvm.
Ich kann die Source-Dateien nicht “builden”.
Fehlermeldung: error: There is no SDK with the name or path ‘iphoneos2.2′
Sollte das Zeug nicht in soweit abwärtskompatibel sein?
Wie kann ich das beheben (Es wird mir nicht angezeigt, welche Datei genau für den Ärger verantwortlich ist)?
Ansonsten: Nettes Tut!
Sh**! I’d had to write in English!
So: I’m not able to build the source data. I always get this error: There is no SDK with the name or path ‘iphoneos2.2′
Does the newest version of XCode not support this code or what?
How can I fix this because XCode doesn’t tell me in which part of the program the error is located.
But this is a very good tutorial!
———————————————–
Sorry for my bad English.
13 Trackbacks
[...] iCodeBlog » Blog Archive » iPhone Game Programming Tutorial Part 3 – Splash Screen. [...]
[...] 37. Game tutorial-3 [...]
[...] The second part talks about user interaction, Simple game AI, game logic etc.The third and the final part contains integration of the [...]
[...] iCodeBlog » Blog Archive » iPhone Game Programming Tutorial Part 3 – Splash Screen (tags: iphone splashscreen) [...]
[...] Текст оригинальной статьи на английском языке [здесь] [...]
[...] following iCodeBlog’s splash screen tutorial, I threw together a placeholder splash screen, the first draft of the sign in page, and [...]
[...] Cocos2d-iPhone Collection of various links Homepage Google group API reference Notes on Cocos2d iPhone Development Move sprite example Introduction to Cocos2d iPhone Monocles Studio Intro Collision particle Great site with lots of simple examples Game walkthrough Sapus Tongue Sources Coloring Sprites Bounching ball 2 Permadi Splash screen [...]
[...] = ‘brandontreb’; It’s been a while, but I finally posted part 3 of the iPhone Game Programming tutorial series on iCodeblog.com. The focus of this tutorial was to create a splash page for your game [...]
[...] “Bubi Devs”. La versione originale inglese del tutorial è disponibile a questo indirizzo: “iPhone Game Programming Tutorial, Part 2 – iCodBlog“. I meriti quindi relativamente alla versione inglese, sono del legittimo [...]
[...] a time. Ok, let’s get started… Make sure you are starting with the base code from the previous tutorial (either use yours or download a fresh copy). We will be using 2 sounds today, 1 for when the ball [...]
[...] a time. Ok, let’s get started… Make sure you are starting with the base code from the previous tutorial (either use yours or download a fresh copy). We will be using 2 sounds today, 1 for when the ball [...]
[...] Mar 2009 原文见:iPhone Game Programming Tutorial Part 3 – Splash Screen 游戏, 编程 编程, 教程, 游戏 [...]
[...] iTennis iPhone Game Tutorial – Lesson 03 [...]