Create Multiple (similar) Levels based game in iphone sdk - iphone

I have this game where balloons are coming from bottom and player has to pop them by tapping before:
Time runs out
OR
10 balloons leave screen unpopped e.g. game over.
Every level is same , only thing changes is number of balloons.
For this i have the following view controllers:
MainLevelVC: The first one, to which the BaloonPopViewController connects when user selects to play game.
LevelIntroVC: This shows an intro screen for 2 seconds for each level, basically an image is loaded based on level count e.f. 1.png, 2.png etc
LevelOutroVC: similar as before but shows an outro screen. 1_outro.png etc
LevelPlayVC: This is where game logic is actually implemented. a link to Main menu (Play, high scores, etc) exists here.
I have done it for one level, there are global variables (basically implemented via a singleton) in MainLevelVC that define max number of balloons allowed to leave screen unpopped (leftBalloons) and number of balloons in the next level (balloonCount). At the end of every level i have to increment the LevelCount global variable as well to facilitate the Level*troVC to do their task easily.
What i am confused about is how to proceed at the end of every level? after i show the LevelOutro for that level increment/decrement any values that i must, how can i reconnect back to LevelIntroVC to start next level?

How are you displaying the view controllers in the first place? If you're using a navigation controller, you can just popToViewController:animated: to get back to your intro VC.
Otherwise, you can probably just keep stacking intro VCs on top of outro VCs in the same way you're currently transitioning from intro VC to play VC to outro VC. Just be careful of your memory usage - release any "old" view controllers you're no longer accessing as soon as you can.

Related

Application runs slower after going multiple times back and fourth through view controllers

When I have this view:
And I click the backpack button I go to this view:
I can move presented items between slots by dragging them with one's finger. This is representation of hero's inventory in which we can equip him with weapons, armor and so on. Everything is stored through Core Data. Every drag-drop re-saves data and every opening of the backpack view fetches it at the start. Thus, memory shouldn't be an issue here.
But when I go back and forth through these views by clicking backpack and Back buttons for like dozens of times then I experience lack of performance if it comes to app's response time and so, item dragging is slow and drops are hard to be made. What causes this? I use touchesBegan, touchesMoved and touchesEnded functions

Loading MKMapview in background to avoid delay issues

I'm building an iPhone app (in iOS 5) with several different views, one of which contains a map (also has separate view controller). The first time I go over to this view, it takes a while for it to load, and things such as animating pin drops also don't work well as a result of it. Not to mention that it takes a bit for the location to stabilize.
What I want to know is if there's a way to load MKMapView before a user goes to that view, so by the time they get there, these issues aren't present anymore.
I've already seen this and this question but they haven't been very helpful. Keep in mind that I don't really need to interact with that view before I get there, I just want it to be fully loaded by the time I go there.

iPhone - Moving a valid advert Offscreen

I have a banner Advert view (could be an iAd or another type) and It loads an advert.
Now after it has loaded, I might want to move it offscreen (for example when I load a complex UI, I dont want to confuse the user, so I hide the ad).
My question is, will the advert know its offscreen? I.e. Will it stop updating its CPM and adjust advertising revenues accordingly, or will I be violating some kind of terms of service by pretending I am showing an advert when really its hidden?
The iAd ADBannerView will detect that it is not visible, so you can assume it will take appropriate action. There is no way to make a categorical statement about any generic advertising program.

displaying different views based on a condition checked in view controller

I want my view controller to display different views based on a condition that depends on some runtime checks (lets say a uiwebview at even hours and a form on odd hours).
What is the best pattern to achieve it in iphone project? Maybe I can hide controls based on aforementioned condition or maybe it is better to load different views?
or maybe i should load different view controllers and make the check in my parent view controller?
The iPhone UI is so small and crowded that you are usually better off creating a different view/view-controller pair for different UIs. Hiding UI elements leaves gaps that are very noticeable and manually rearranging the UI elements on the fly is a pain.
More importantly, different views communicate to the user that the app is in a different state. You don't want the app to switch to a different state without informing the user. It's hard enough for them to understand what is going on without confusing them with UI slight of hand.
It is very bad UI design to have the same user action present a different UI for no reason discernible to the user. For example, presenting a "a uiwebview at even hours and a form on odd hours" would be a fantastically bad idea because the user would have no idea why clicking on a specific button sometimes gets them a web view and a form view other times. Do you expect the user to check the clock before clicking so that they know what to expect?
If some UI element is unavailable for some reason e.g. no network access, then it's better UI design to present the element as disabled instead of disappearing it. The interface grammar teaches users that grayed out controls are temporarily unavailable. That is much less confusing that a constantly changing UI.

How to use Sleep in the application in iphone

I have used to loading a default image in my appication. So i have set to,
Sleep(3); in my delegate.m class.
But sometimes it will take more than 6 to 7 minutes. So i want to display the image 3 seconds only and then it goes to my appilcation based on my requirements.
Which one is best way to do that?
Sleep(3) or [NSThread sleepForTimeInterval:3.0] or something else;
And i must display the image 3 seconds only. Please explain me.
(Note: And I declared setter and getter methods only in my deleagte class.)
Please explain me.
As Rob noted, Apple strongly recommends against a splash screen unless it hides some necessary behind the scenes process (like loading game graphics.) It is so strongly discouraged that some people have claimed that their apps have been rejected for using an unnecessary splash screen.
The default.png doesn't exist to create a splash screen. Instead it exist to allow you to create the illusion that your initial view loads faster than it does. You supposed to use it to provide an image of your initial view so that the enduser can begin to cognitively orient themselves to the interface. By the time they have oriented themselves to the interface and moved their finger to touch the interface, it is live.
Why? Because iPhone apps are supposed be quick in, quick out. People don't sit down to use them at a desk like a desktop. People use then on the go. Sometimes they use them in the middle of a conversation.
I tell my clients to test out the usability of their apps (except for games) while walking, riding an exercise bike etc as well as in the middle of a face-to-face and phone conversation. In those circumstances, a three second pause is a big deal and very noticeable especially if the app is a practical app. Imagine if every time you opened the Contact app you had to pause three seconds to see an Apple splash screen. You would get peeved in a hurry.
The key thing here is that an unnecessary splash screen doesn't add any value for the user. It is a selfish act on the part of the software publisher to eat the end users time so that the publisher can build brand recognition for the sole benefit of the publisher. Wasting three seconds of the users time every time they use the app adds up in a hurry. (In my experience, it also makes the user perceive that the overall app is slow and clunky.)
However, if you do want to shoot yourself in the foot or if you have a client hell bent on a splash screen, you do it like this:
The splash screen appears until the first view loads so you delay the loading of the first view. In the app delegates applicationDidFinishLaunching: method, remove all the code that loads the first view into the window. Replace it with a NSTimer. Put the code to load the first view in the timer's fire method.
With that setup the app will display the default.png as it launches, when it gets to applicationDidFinishLaunching:it will appear to pause from the end users perspective because no view will appear to replace the default.png.
You should note that the standard launch time for an app is 3-5 seconds. So you may not have to do anything to show the splash screen for 3 seconds. It might happen automatically.
Apple strictly recommends against this (using sleep in this way), especially in the scenario of showing a splash screen.
The best thing to do is create a view that looks like your Default.png file, then have that be the first NIB.. you could then set an NSTimer to transition (with animation if you want) to your main view/window/controller.