Game Development Reference
In-Depth Information
Kobold2D therefore supports locale-independent keyboard input based on key codes.
You can check whether the D key was pressed in Kobold2D like this:
[[KKInput sharedInput] isKeyDownThisFrame:KKKeyCode_D];
This works independently of whether the user has had the Shift key pressed or not. To
include the Shift key in the check, simply write:
KKInput* input = [KKInput sharedInput];
[input isKeyDownThisFrame:KKKeyCode_D modifierFlags:KKModifierShiftKeyMask];
Kobold2D users don't need to delve further into this subject because Kobold2D already
provides solid, documented keyboard and mouse input implementation: + User+Input . But
cocos2d users can learn more about keyboard event handling in this forum thread: . Apple's documentation on
handling key events is also very helpful:
HandlingKeyEvents/HandlingKeyEvents.html .
Receiving Mouse Events
Similar to all other input methods, you first have to enable mouse input via the follow-
self.isMouseEnabled = YES;
Then your layer will start receiving CCMouseEventDelegate protocol messages,
of which there are quite a few:
// received when the mouse moves with no button pressed
-(BOOL) ccMouseMoved:(NSEvent*)event {}
// received when the mouse moves while the corresponding button is held down
-(BOOL) ccMouseDragged:(NSEvent*)event {}
-(BOOL) ccRightMouseDragged:(NSEvent*)event {}
-(BOOL) ccOtherMouseDragged:(NSEvent*)event {}
Search Nedrilad ::

Custom Search