Home > other >  Could you tell me how to distinguish between cocos2d - x to monitor mouse buttons
Could you tell me how to distinguish between cocos2d - x to monitor mouse buttons

Time:09-29

Could you tell me how to distinguish between cocos2d - x to monitor mouse buttons?

CodePudding user response:

Met before this, if want to achieve, the engine is not to distinguish the or so key inside

CodePudding user response:

_mouseListener=EventListenerMouse: : create ();
_mouseListener - & gt; onm ouseUp=CC_CALLBACK_1 (MouseEventTest: : onm ouseUp, this);
_mouseListener - & gt; onm ouseDown=CC_CALLBACK_1 (MouseEventTest: : onm ouseDown, this);
Void MouseEventTest: : onm ouseDown Event (Event *)
{
EventMouse * e=(EventMouse *) event;
STD: : string STR="Mouse Down detected, Key:";
STR +=tostr (static_cast & lt; int> (e - & gt; GetMouseButton ()));
_labelAction - & gt; SetString (STR) c_str ());
}

Void MouseEventTest: : onm ouseUp Event (Event *)
{
EventMouse * e=(EventMouse *) event;
STD: : string STR="Mouse Up detected, Key:";
STR +=tostr (static_cast & lt; int> (e - & gt; GetMouseButton ()));
_labelAction - & gt; SetString (STR) c_str ());
}
The left mouse button to return to zero right returns 1
  • Related