Skip to content

Add touch event listeners for mobile movement tracking in speed modifier component#18

Merged
MakingSpiderSense merged 1 commit into
mainfrom
bugfix/movement-speed-modifier/118-show-speed-lines-on-mobile
Jun 17, 2026
Merged

Add touch event listeners for mobile movement tracking in speed modifier component#18
MakingSpiderSense merged 1 commit into
mainfrom
bugfix/movement-speed-modifier/118-show-speed-lines-on-mobile

Conversation

@MakingSpiderSense

@MakingSpiderSense MakingSpiderSense commented Jun 17, 2026

Copy link
Copy Markdown
Owner

This pull request improves support for mobile touch input to the movement-speed-modifier component. The main changes include tracking touch events, updating movement logic to recognize touch-based movement, and ensuring that speed lines show up when moving forward on mobile.

Mobile touch input support:

  • Added touchCount property and methods (onTouchStart, onTouchEnd) to track the number of fingers on the screen, and update movement state accordingly. [1] [2]
  • Implemented addTouchListeners and removeTouchListeners methods to manage touch event listeners during component lifecycle. [1] [2]

Movement logic updates:

  • Modified the isMovingForward method to support forward movement when one finger is on the screen (two fingers moves the player backwards, so that would register as false), allowing for mobile-friendly movement controls.

Trello: https://trello.com/c/GmhnPkKL

Copilot AI review requested due to automatic review settings June 17, 2026 19:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the movement-speed-modifier A-Frame component to recognize mobile touch activity as an additional “moving forward” signal, primarily to keep speed-line visibility in sync with touch-based movement.

Changes:

  • Added touchCount state and touch start/end handlers to track the number of active touches.
  • Added lifecycle-managed touchstart/touchend/touchcancel listeners.
  • Updated isMovingForward() to include single-touch as a forward-movement indicator.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +158 to +162
addTouchListeners: function () {
window.addEventListener("touchstart", this.onTouchStart);
window.addEventListener("touchend", this.onTouchEnd);
window.addEventListener("touchcancel", this.onTouchEnd);
},

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and there were no warnings. Scroll performance is not applicable for A-Frame scenes.

Comment on lines +169 to +173
removeTouchListeners: function () {
window.removeEventListener("touchstart", this.onTouchStart);
window.removeEventListener("touchend", this.onTouchEnd);
window.removeEventListener("touchcancel", this.onTouchEnd);
},

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not applicable.

Comment on lines +341 to +342
const touchMovingForward = this.touchCount === 1; // 1 finger = forward, 2 = backward
return keyboardMovingForward || joystickMovingForward || armSwingMovingForward || touchMovingForward;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't need to check this.data.enabled since speed line visibility is blocked at the tick() level.

Comment on lines +270 to +273
onTouchStart: function (event) {
this.touchCount = event.touches.length;
this.syncSpeedLinesVisibility();
},

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

const joystickMovingForward = this.isJoystickForward();
const armSwingMovingForward = armSwingMovement && armSwingMovement.moving && !armSwingMovement.reverseHeld;
return keyboardMovingForward || joystickMovingForward || armSwingMovingForward;
const touchMovingForward = this.touchCount === 1; // 1 finger = forward, 2 = backward

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the touch-controls component that treats it this way.

@MakingSpiderSense MakingSpiderSense merged commit 75fe95c into main Jun 17, 2026
1 check passed
@MakingSpiderSense MakingSpiderSense deleted the bugfix/movement-speed-modifier/118-show-speed-lines-on-mobile branch June 17, 2026 19:34
@MakingSpiderSense MakingSpiderSense restored the bugfix/movement-speed-modifier/118-show-speed-lines-on-mobile branch June 17, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants