There are two types of pictures above.
Area 1 represents a moving character. You can enter the direction key + space bar key and move and jump according to the key.
Area 2 allows multiple chats by entering letters in input. Chatting is displayed in the Intermediate Chat list.
I want to mark the chat here so that I can follow the characters in the Canvas area.
(Like a regular RPG game chat system)
(To display the chat contents on the character as you move the character)
However, it is difficult because the canvas area is continuously drawn as setInterval().
Is there a way to separate it and implement it...
git address. You can test it easily by git clone.
https://github.com/zealot71/chat_rpg.git
ps. I got an answer yesterday asking you to refer to http://codecanyon.net/item/virtualspaces-socketio-virtual-chat-room/13678953 but I'm almost done, so I'm asking you a code implementation question...
socket.io canvas html5 javascript chatting
I think you're almost there, so I think you can go a little further.
To give you a simple answer, when you draw a character on the screen, you have to draw the letters together.
If you receive a keyboard event now, don't you update the specific data and draw it on the screen?
Likewise, when you receive chat information on the socket, you can share what you do below, not draw it on the screen right away.
First, update the data by including what you want to draw in the chat in the data containing the characters (as if responding to a keyboard event).
Draw the corresponding data (chat) with the character on the screen in the renderer drawing the screen at a specific interval
© 2024 OneMinuteCode. All rights reserved.