Author Topic: OnConstantPress event ?  (Read 3310 times)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
OnConstantPress event ?
« on: November 19, 2013, 09:47:23 AM »
Hi!

It seems weird but... I can't find anywhere an event that will be call every frame while the user is pressing a button. Am I missing it?

Thanks.

N3uRo

  • Guest
Re: OnConstantPress event ?
« Reply #1 on: November 19, 2013, 12:15:42 PM »
Hi!

It seems weird but... I can't find anywhere an event that will be call every frame while the user is pressing a button. Am I missing it?

Thanks.

Workaround...

  1. bool pressed;
  2.  
  3. void OnPress(bool pressed) {
  4.  this.pressed = pressed;
  5. }
  6.  
  7. void OnConstantPress() {
  8.   // Code
  9. }
  10.  
  11. void Update() {
  12.  if (pressed) {
  13.   OnConstantPress();
  14.  }
  15. }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnConstantPress event ?
« Reply #2 on: November 19, 2013, 08:33:59 PM »
Yeah there is no constant event. Just set a local flag and check it in Update.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: OnConstantPress event ?
« Reply #3 on: November 25, 2013, 04:04:46 AM »
Thanks to both of you, that's what I did.