I want to create an Input function like Unity with cocos2d-x.

Asked 2 years ago, Updated 2 years ago, 119 views

I am a student who uses cocos2d-x 3.10 to create games.

Create a listener on the cocos2d-x EventListenerKeyboard and
Instead of putting functions in onKeyPressed in advance,


such as Unity, bool Input::GetKeyDown (KeyCode keyCode), etc. I'd like to implement a function that determines whether it's pressed, pressed, or detached.

I can't think of what to implement.

If you don't mind, please reply.

c++ cocos2d-x

2022-09-30 21:14

1 Answers

According to the Cocos document, you can use the listener EventListenerKeyboard to determine keyboard events.

According to the original code example, you can first use the lines , EventListenerKeyboard::create() and then use functions such as onKeyPressed and onKeyReleased.


2022-09-30 21:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.