ControlButton 事件
#ifndef__ControlButton_H__#define__ControlButton_H__#include"cocos2d.h"#include"cocos-ext.h"USING_NS_CC;USING_NS_CC_EXT;//用于标识当前按钮的状态typedefenum{touch_begin,touch_down,touch_up,}tagForTouch;classControlButton:publicCCNode{public:ControlButton();~ControlButton();CREATE_FUNC(ControlButton);//创建按钮,其中name_png为按钮的背景图片,button_title为按钮图片上要显示的文字,num为文字的透明度0-100,0为透明voidCreateButton(constchar*name_png,constchar*button_title="0",unsignedintnum=0);//绑写按钮事件voidBindButtonEven();/*当鼠标处于按下并曾经点中按钮时,则触发一次*/voidtouchDownAction(Ref*pSender,Control::EventTypeevent);/*当鼠标处于按下并曾经点中按钮的状态下,鼠标进入按钮范围,则触发一次*/voidtouchDragEnter(Ref*pSender,Control::EventTypeevent);/*当鼠标处于按下并曾经点中按钮的状态下,鼠标离开按钮范围,则触发一次*/voidtouchDragExit(Ref*pSender,Control::EventTypeevent);/*当鼠标处于按下并曾经点中按钮的状态下,鼠标进入按钮范围,则触发,只要达到条件,就不断触发*/voidtouchDragInside(Ref*pSender,Control::EventTypeevent);/*当鼠标处于按下并曾经点中按钮的状态下,鼠标离开按钮范围,则触发,只要达到条件,就不断触发*/voidtouchDragOutside(Ref*pSender,Control::EventTypeevent);/*当鼠标处于按下并曾经点中按钮的状态下,鼠标松开且在按钮范围内,则触发一次*/voidtouchUpInside(Ref*pSender,Control::EventTypeevent);/*当鼠标处于按下并曾经点中按钮的状态下,鼠标松开且在按钮范围外,则触发一次*/voidtouchUpOutside(Ref*pSender,Control::EventTypeevent);/*暂时没有发现能用鼠标触发这个事件的操作,看了注释,应该是由其它事件中断按钮事件而触发的*/voidtouchCancel(Ref*pSender,Control::EventTypeevent);//是否按下按钮boolisTouch;private://按钮控件变量ControlButton*controlBtn;};#endifevent枚举如下:/**Kindsofpossibleeventsforthecontrolobjects.*/enumclassEventType{TOUCH_DOWN=1<<0,//Atouch-downeventinthecontrol.DRAG_INSIDE=1<<1,//Aneventwhereafingerisdraggedinsidetheboundsofthecontrol.DRAG_OUTSIDE=1<<2,//Aneventwhereafingerisdraggedjustoutsidetheboundsofthecontrol.DRAG_ENTER=1<<3,//Aneventwhereafingerisdraggedintotheboundsofthecontrol.DRAG_EXIT=1<<4,//Aneventwhereafingerisdraggedfromwithinacontroltooutsideitsbounds.TOUCH_UP_INSIDE=1<<5,//Atouch-upeventinthecontrolwherethefingerisinsidetheboundsofthecontrol.TOUCH_UP_OUTSIDE=1<<6,//Atouch-upeventinthecontrolwherethefingerisoutsidetheboundsofthecontrol.TOUCH_CANCEL=1<<7,//Asystemeventcancelingthecurrenttouchesforthecontrol.VALUE_CHANGED=1<<8//Atouchdraggingorotherwisemanipulatingacontrol,causingittoemitaseriesofdifferentvalues.};
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。