Thread: Zune Stop Watch
View Single Post
Old 06-11-2008, 11:50 AM   #24 (permalink)
ShotgunSnipist
Experienced Member
 
ShotgunSnipist's Avatar
 
Join Date: May 2008
Location: Colorado
Posts: 803
ShotgunSnipist has a spectacular aura aboutShotgunSnipist has a spectacular aura about
Send a message via AIM to ShotgunSnipist
Default

Quote:
Originally Posted by LedZepp View Post
Use a boolean.
Declare something like:
bool pressed = false;

Now just modify your DPad.B(Play/Pause) code to look like this:

if (!pressed && GamePad.GetState(PlayerIndex.One).DPad.B == ButtonState.Pressed)
{
your code here
pressed = true;
}
if (pressed && GamePad.GetState(PlayerIndex.One).DPad.B == ButtonState.Released)
{
pressed = false;
}

What this does is it checks for a boolean to be false when pressing the button, if its false it carries the code under it out and then makes the boolean true therefore not letting it loop again until you release the button and it makes the boolean false again.
THANKS!
Works great.

Update: This will be used to make the music run smoother as well. So just hang on while I fix this.

Okay, so now, the timer doesn't lag for 100ms every time you adjust the music or volume. And now, because the play button now does play AND pause with no annoying mistakes, the center button is essentially useless. So i'm thinking about putting a menu in when you press it (mainly so I can extend my C# experience and learn something) But i'll try to add something like changing the background or something awesome like that. =D

I'll re-upload the new version: v0.25
__________________
Invisible Text. =P

Last edited by ShotgunSnipist; 06-11-2008 at 12:13 PM.



ShotgunSnipist is offline   Reply With Quote