Handling input, playing sounds and so on...

Handling input, playing sounds and so on...
0.0 0



i am studying cocos2dx since i have to write a 2D game with it (my first game with a unknown 2D engine…heeeelp).

The game should run on iPhone and Android phones (and Windows mainly for debugging purpose).

What i would like to ask is how to handle user input with cocos2dx. Win platform allow user input to be processed
in a callback (the WindowProc). How is user input handled? Is there a queue where all user inputs are inserted and
processed later when the game update method is called or are they processed immediately???

Another question is: suppose there is a collision between two objects. Should i play the sound imediately or should i queue
the “play sound action” somewhere and cocos handle the call to the “playSound()” method?



Welcome to cocos2d-x community.

# ccx handles user input, mainly touch events from CCTouchDispatcher to CCTouchDelegate. And CCTouchDelegate is inherited by CCLayer. So you can get touch msgs by there steps
#* call CCLayer::setIsTouchEnabled(true);
#* overwrite CCLayer::ccTouchesBegan(…), ccTouchesMoved(…), ccTouchesEnded(…) methods in your layer
#* Please refer to the sources in tests/TouchesTest
# keyboard input is supported on only android (without win32). setIsKaypadEnabled(true) & overwrite CCLayer::keyBackClicked(), keyMenuClicked()
# You should invoke SimpleAudioEngine::playEffect manually when collision occurs.