How to detect if back button has been pressed on windows phone 7?
-
I have searched for this for ages but I can't find an answer that applies to me. I'm using cocos2d for xna and am trying to make it so when the user presses the back button on the windows phone, the application won't close I saw that on xna your supposed to use if (GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One).Buttons.Back == ButtonState.Pressed) But cocos2d doesn't have an update method, so I tried overriding the update method like this public override void update(float dt) { Debug.WriteLine("testing"); if (GamePad.GetState(Microsoft.Xna.Framework.PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { int i = 10; Debug.WriteLine("LOL"); } base.update(dt); } But that method doesn't fire. Another thing I came acroswas the NavigationService.navigate method, but thats used in the standard silver light stuff and not for moving between c.s files in cocos2d. Can anyone tell me what I need to do? Thanks in advance
-
Answer:
This is the correct way to detect a back button press: if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { } I'm not sure how Cocos2D works, but wherever you are doing your game logic, that is where you'd put this code. I would imagine that you have a Game class, and you should have an Update method in the game class, that calls Cocos2D update logic, I would put this there. Can you elaborate on where you put the code above?
user819640 at Stack Overflow Visit the source
Related Q & A:
- How to do HttpWebRequests from a Windows Phone 7?Best solution by stackoverflow.com
- How can I use a button to retrieve a phone 'number' from contacts?Best solution by Stack Overflow
- Locked out of Windows XP, how do I get back in?Best solution by Super User
- How to detect invisible Windows Live Messenger users?Best solution by Yahoo! Answers
- How do I check what Graphics Card I have on Windows 7?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.