Answer the question
In order to leave comments, you need to log in
How to get a variable from an anonymous function? How do I get the X position of the mouse to be passed to the platform object?
let position = document.getElementById('position')
let mx
function callback(event){
mx = event.pageX
}
window.onmousemove = callback
console.log(mx)
let platform = {
x: mx - 100,
y: 575,
width: 200,
height: 25,
color: 'blue'
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question