update() { this.x += this.directionX; if(this.x > canvas.width + this.radius) { this.x = -this.radius; } this.render(); } åºæ¬çãªãã¼ãã£ã¯ã«ã§ã¯ãä¸è¨ã®ããã«ã丸ã®ä½ç½®ãå°ããã¤åãããã¨ããå¦çããã¦ãã¾ãã ä»åã¯ãããã®updateã®å¦çã®ä¸ã§è¨ç®ããã¾ãã ãã¦ã¹ã®ä½ç½®åå¾ ã¾ãããã¦ã¹ã®ä½ç½®ãåå¾ããå¿ è¦ãããã¾ãããã®ããã«mousemoveã¤ãã³ããç»é²ãããã¦ã¹ã«ã¼ã½ã«ã®ä½ç½®ãå¤æ°ã«å ¥ãã¦ããããã«ãã¾ãã const mouse = { x: null, y: null } window.addEventListener('mousemove', (event) => { mouse.x = event.x; mouse.y = event.y; }
{{#tags}}- {{label}}
{{/tags}}