how to reset game in cocos2d - cocos2d-iphone

My question in the previous post was-
I have a cocos2d game, and after I
exit the game and start it again, it
starts at the exact same point it was
before closing.why this is
happening??and not only this, my game
is landscapemode but when I start it
again from simulator it comes in
portrait mode,not it landscapemode like
first time.
Is there any way to prevent this?
Anyone will come to rescue me???
I found a solution.Is it good??
when I exit the game(by pressing the back button in iPhone simulator) this problem occurred. Now I found that if I press back button the following function is called-
(void)applicationWillResignActive:(UIApplication *)application
So I set (divide by zero) or something like this in -(void)applicationWillResignActive function so that when this function called the application crashes. Then if I restart the application everything comes from beginning(reset) which I want. Is it good solution or anything better?
*my applicationDidFinishLaunching was not called again when application is restart from simulator.

You should configure the Info.plist to indicate that you does not want your application run in Background.
The key is
UIApplicationExitsOnSuspend
If you need more detail you should look at this tutorial

If you have iOS 4.0 or higher, multitasking is causing your problem.

Related

Why is my button firing twice?

I have a CButton as part of a CDialog screen. Everything works fine, but after I reinitialize a hardware device, when I click anywhere on the screen (even outside the dialog) the event for the CButton in question fires. I've run through the code in debugger mode, and the app literally thinks the button in question is being pressed. Thing is, its NOT being pressed. I've experimented with clearing the message pump, but that didn't seem to help. If you need code, let me know and I'll see what I can drum up without giving away how our app works. I get the feeling this is an edge case that others have run into and know how to solve without code.
Thanks in advance!

Qt how to properly do a screensaver function windows C++

I have to do an touchscreen app for windows, and if the customer hasnt click for 60sec on the screen, a little video or advertsing appears (and leave right after the customer's clik).
I've already made my own thread function for that (a simple loop with a usleep), but i dont think its a good way.
I'm seeking for an obj or something else with Qt that could be better, any ideas?
I'm not sure I fully understand your question but it sounds like you want to listen to QTMouseEvents. Specifically it sounds like you'll be interested in events of type QEvent::MouseButtonPress. Start a timer on a click, once it reaches 60 seconds (note: reset the timer on each click) then start playing the video. Another event of that type will then allow you to 'restore' the main window app (if the video is playing)

C++ MFC Software request focus at startup (blink in task bar)

I have a C++ software based on MFC (CDialog). When it starts it is always requesting for focus, mean it is blinking in the windows task bar.
The issue is that task bar is suppose to be set in out hide mode (because I have some other UI that are supposed to cover the full screen). But since this software always request focus, windows task bar never hide until I show and hide this piece of software...
I have other MFC softwares that do not have this behaviour but so far I cannot find out what could be the difference !
If someone had a idea that would be nice !
Thanks in advance.
Looks like I am doing some progress...
If I had ShowWindow(SW_SHOWNORMAL); just before the return of the OnInitDialog() function, then I don't get this behaviour anymore.
That is of course not perferct because I would like this application to be minimized and silent at startup, but when I try ShowWindow with other agrument I always get this flashing issue back...
Any other ideas are welcome ! Thanks.

Player Disconnect Issue GKMatch and Gamekit

i am working with cocos2d game with GameKit. I am creating match with 2 player using GKMatch. All thing is working fine for me but When one player enters the background state or pressing home button , then player is disconnected. I want to run GKMatch instance in background also. Please help me.
Thanks in advance.
I don't think that's possible, after all "background" means the player stopped playing.
While the programming guide might not mention that explicity, it does one thing, namely automatically logging in the player when the application enters foreground, which to me indicates there's simply no player GKMatch could be connected with while the app is in the background.

cocos2d game reset problem

I have a cocos2d game, and after I exit the game and start it again, it starts at the exact same point it was before closing.why this is happening??and not only this, my game is landscapemode but when i start it again from simulator it comes in potrait mode,not it landscapemode like first time.
Is there any way to prevent this?
Anyone will come to rescue me???
From iOS 4.0, there are new options for "info.plist" file.
If you do not want to add multi-tasking(running in background), just add it.
You can add the option by just clicking and checking in your game project's "info.plist".
And rotation setting is on your "RootViewController.m" file.
You can change your app direction by just changing return value.
I hope your game will work well.