-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystems.js
More file actions
21 lines (17 loc) · 760 Bytes
/
systems.js
File metadata and controls
21 lines (17 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const MoveFinger = (entities, { touches }) => {
//-- I'm choosing to update the game state (entities) directly for the sake of brevity and simplicity.
//-- There's nothing stopping you from treating the game state as immutable and returning a copy..
//-- Example: return { ...entities, t.id: { UPDATED COMPONENTS }};
//-- That said, it's probably worth considering performance implications in either case.
touches.filter(t => t.type === "move").forEach(t => {
let finger = entities[t.id];
if (finger && finger.position) {
finger.position = [
finger.position[0] + t.delta.pageX,
finger.position[1] + t.delta.pageY
];
}
});
return entities;
};
export { MoveFinger };