canvas, socket.io implemented. Now, I want to display the chat above the character. (git example sharing)

Asked 2 years ago, Updated 2 years ago, 105 views

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...

Share the
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

2022-09-22 13:39

1 Answers

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


2022-09-22 13:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.