Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / what am i doing wrong , please please help

Author
Message
haliop
User Banned
Posted: 3rd Apr 2013 17:46


as i understand using this method discOn should be 1 or 0 even if i still press the virtual button.

but for some reason the text flickers for one sec then dissapears..

why is that?

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd Apr 2013 17:59
I have discovered that in Tier 1, the GetVirtualButtonPressed will sometimes return 1 for longer than expected.

First, are you doing a Sync() call at least once after the description display toggle?

Next, try putting this line after the "else if discOn = 1 then discOn = 0" one:
while GetVirtualButtonPressed(2) = 1: Sync(): endwhile

(or break it up into three lines)

This should make sure that you only 'catch' one press every cycle.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 3rd Apr 2013 18:03
I think it'll be because the virtual button is registering the press for several frames, rather than just one. So if you have a delay, or a reset for the button press, then you would have more control. Like:

// setup
disc = 0

// in loop
// discription button
if GetVirtualButtonExists(2) = 1
if GetVirtualButtonPressed(2) = 1
if PRESSING=0
if discOn = 0 then discOn = 1
else if discOn = 1 then discOn = 0
PRESSING=1
endif
else
PRESSING=0
endif
endif


So if the button isn't pressed, PRESSING will be 0 - as soon as you press the button, PRESSING will be 1, and stay at 1 while you press it.
If you need a lot of buttons, maybe worth having a PRESSING array, and make it a standard.

Ohh, and quick tip - to change discOn between 1 and 0, just do this:

discOn=1-discOn

I got a fever, and the only prescription, is more memes.
haliop
User Banned
Posted: 3rd Apr 2013 18:16
yes there is a sync() after... ofcourse there is


still i didnot understand what to do ...
can someone write it in
?

and thanks for the quick response! this just show what a great community AppGameKit have.

haliop
User Banned
Posted: 3rd Apr 2013 18:18
and i just need this button to work like this :/

haliop
User Banned
Posted: 3rd Apr 2013 18:19
i got about 20 buttons overall all work great but only this one have a boolean op in it.. to show or not to show the text.. i just cant figure out what to do ... sorry if this seems stupid or something.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd Apr 2013 18:26
This will make sure that you don't get multiple frame hits on the button when you don't want to:


Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
haliop
User Banned
Posted: 3rd Apr 2013 18:51
this dosent work ...



Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd Apr 2013 19:18
What do you mean by "it doesn't work"? What behavior are you seeing?

The first time you showed the code, you had the 'if discOn = 1' set of code after the other.

Also you can replace that bit with one line:


In fact, you can can replace a lot:


Are you sure that the discOn variable isn't being set anywhere else?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 3rd Apr 2013 19:51
by the way, i think this:

if discOn = 0 then discOn = 1
else if discOn = 1 then discOn = 0

=

discOn = 1 - discOn
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd Apr 2013 20:17
Quote: "discOn = 1 - discOn"

Yup, that is much better than my suggestion of
Quote: "discOn = Mod(discOn+1,2)"


Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
haliop
User Banned
Posted: 3rd Apr 2013 23:06


works like a charm! ty

Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 4th Apr 2013 19:41
If your only using discOn to flag the text change, you could change;

to;
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th Apr 2013 22:24
That works, but it adds an extra function call, which will take many more machine cycles than the simple math function.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-05-05 21:46:46
Your offset time is: 2024-05-05 21:46:46