瀏覽代碼

Fixed bug : touches become sticky (#2857)

Touches became sticky and didn't disappear after using more than 2 fingers, fixed by getting the touch count of how many fingers are on the screen, and only looping through the available/pressed down touch points instead of looping through the maximum touch points.
Tested with more than 10 touch points, and with different MAX points value, working perfectly.
pull/2860/head
Ghost 2 年之前
committed by GitHub
父節點
當前提交
2a2f2b20b8
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: 4AEE18F83AFDEB23
共有 1 個檔案被更改,包括 8 行新增4 行删除
  1. +8
    -4
      examples/core/core_input_multitouch.c

+ 8
- 4
examples/core/core_input_multitouch.c 查看文件

@ -39,8 +39,12 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
// Get multiple touchpoints
for (int i = 0; i < MAX_TOUCH_POINTS; ++i) touchPositions[i] = GetTouchPosition(i);
// Get the touch point count ( how many fingers are touching the screen )
int tCount = GetTouchPointCount();
// Clamp touch points available ( set the maximum touch points allowed )
if(tCount > MAX_TOUCH_POINTS) tCount = MAX_TOUCH_POINTS;
// Get touch points positions
for (int i = 0; i < tCount; ++i) touchPositions[i] = GetTouchPosition(i);
//----------------------------------------------------------------------------------
// Draw
@ -49,7 +53,7 @@ int main(void)
ClearBackground(RAYWHITE);
for (int i = 0; i < MAX_TOUCH_POINTS; ++i)
for (int i = 0; i < tCount; ++i)
{
// Make sure point is not (0, 0) as this means there is no touch for it
if ((touchPositions[i].x > 0) && (touchPositions[i].y > 0))
@ -72,4 +76,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}

Loading…
取消
儲存