Touch xy seem to be duplicated under heavy load

Posted on
  • Hi all, I noticed that under heavy load, the touch event gets fired appropriately, however the xy coordinates are sometimes wrong (to be precise: they are a duplicate of the previous touch event).

    Trying out this code

    Bangle.on('touch', function(button, xy) {
      console.log("coords are", xy);
    setInterval(() => {
      for (let i = 0; i < 40; i ++) {
    }, 50);

    and then quickly touching the screen, alternating between the upper edge and lower edge, does register the correct amount of events, however a quick top, bottom, top tap results in this console log

    coords are { "x": 103, "y": 9, "type": 0 }
    coords are { "x": 117, "y": 8, "type": 0 }
    coords are { "x": 117, "y": 8, "type": 0 }

    It doesn't reproduce every single time, however it happens often. Any idea how this could be fixed?

    Thank you

  • And as I don't want to open another thread but also couldn't find good references: Are there some general tips on how to optimize the performance while programming for the Bangle.js 2? In my game I'm drawing a bunch of shapes - quite rapidly.

  • Interesting - thanks! As I understand it the last touch position is stored, but if something is taking a long time to draw previous positions will be left. It's sort of intentional as for things like scrolling, you want to redraw as fast as you can but you don't want to queue up redraws for previous scroll events.

    Honestly, I feel like if your game is taking so long to render a frame that this is an issue, that might itself impact the playability of the game?

    There are some hints for speed on that might help you I guess?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Touch xy seem to be duplicated under heavy load

Posted by Avatar for momo @momo