Register
Site Login
Site Search
Forums
Advertisement
Welcome to PocketMatrix. PocketMatrix is dedicated to providing the best online community for mobile device developers and enthusiests. What's new?

Holding down buttons?


Holding down buttons?

Postby Rick81 » Oct 25, 2005 @ 6:27pm

I am new to pocket pc programming and I don't know how to check if buttons are held down, for example holding left will make a spaceship turn left.

In my game/demo have the following code for detecting buttons

void game::ButtonDown(int button) {

if(button == m_keys.vkUp)
{
rikt =1;
rx = 0;
ry = -1;
}
if(button == m_keys.vkDown)
{
rikt = 3;
}
and so on....
I want to have like this instead:
if(button held down)
{
angle = angle +1;
}
probably in the main loop, since void game::ButtonDown(int button) is on called once a button is press.
Rick81
pm Member
 
Posts: 1
Joined: Oct 25, 2005 @ 6:18pm


Postby Presto » Oct 25, 2005 @ 6:47pm

Check this thread:
http://www.pocketmatrix.com/forums/view ... hp?t=22413

In PocketFrog, it's basically the same thing. When ButtonDown() or ButtonUp() is called, change the state variable, and check the variable during GameLoop(). If you want to use just one variable for all the button data, you can assign each button a value like 1,2,4,8,16,32,64,128 and add/subtract that amount for button presses/releases, but I generally like to use booleans for it.

-John
User avatar
Presto
pm Insider
 
Posts: 763
Joined: Jan 20, 2003 @ 5:51am
Location: Kalesian Archipelago


Return to PocketFrog & PocketHAL


Sort


Forum Description

SDKs for fast and robust device-independent access to Pocket PC display hardware.

Moderators:

sponge, Kzinti

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron