Answer the question
In order to leave comments, you need to log in
How to pass element position to other connected clients after event.target.prepend()?
Just learning Node.js and Socket.io.
There is a function on the client.
function GameMap(event) {
let target = event.target;
switch(target.className) {
case 'coast':
Place('img/coast.jpg');
break;
case 'water':
Place('img/water.png');
break;
case 'land':
Place('img/land.jpg');
break;
}
if (flag == true && (target.className == 'land' || target.className == 'coast')) {
target.prepend(player);
socket.emit('move', 'НАХУЙ');
flag = false;
flag2 = false;
} else if (flag3 == true && (target.className == 'land' || target.className == 'coast')) {
playermenu.style.display = "none";
flag2 = false;
flag3 = false;
}
socket.on('move2', function(data) {
coast2.innerHTML = data;
});
}
socket.on('move', function(data) {
io.emit('move2', data);
});
socket.on('move2', function(data) {coast2.innerHTML = data;});
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