# ifndef __ControlButton_H__
# define __ControlButton_H__
# include “cocos2d.h”
# include “cocos-ext.h”
USING_NS_CC;
USING_NS_CC_EXT;,//用于标识当前按钮的状态
enum {typedef
,,,touch_begin,
,,,touch_down,
,,,touch_up,
}tagForTouch;
class ControlButton : public CCNode
{
公众:
,,,ControlButton ();
,,,~ ControlButton ();
,,,CREATE_FUNC (ControlButton);
,,,//创建按钮,其中name_png为按钮的背景图片,button_title为按钮图片上要显示的文字,num为文字的透明度0 - 100,0为透明
,,,void CreateButton (const char *, name_png, const char *, button_title=" 0 ", unsigned int num=0);
,,,//绑写按钮事件,
,,,void BindButtonEven ();
,,,/*,当鼠标处于按下并曾经点中按钮时,则触发一次,*/,
,,,void touchDownAction (Ref *, pSender,,控制::EventType 事件),,
,,,/*,当鼠标处于按下并曾经点中按钮的状态下,鼠标进入按钮范围,则触发一次,*/,,
,,,void touchDragEnter (Ref *, pSender,,,控制::EventType 事件),,,
,,,/*,当鼠标处于按下并曾经点中按钮的状态下,鼠标离开按钮范围,则触发一次,*/,,
,,,void touchDragExit (Ref *, pSender,,,控制::EventType 事件),,,
,,,/*,当鼠标处于按下并曾经点中按钮的状态下,鼠标进入按钮范围,则触发,只要达到条件,就不断触发,*/,,
,,,void touchDragInside (Ref *, pSender,,,控制::EventType 事件),,,
,,,/*,当鼠标处于按下并曾经点中按钮的状态下,鼠标离开按钮范围,则触发,只要达到条件,就不断触发,*/,
,,,void touchDragOutside (Ref *, pSender,,,控制::EventType 事件),,,
,,,/*,当鼠标处于按下并曾经点中按钮的状态下,鼠标松开且在按钮范围内,则触发一次,*/,,,void touchUpInside (Ref *, pSender,,,控制::EventType 事件),,,
,,,/*,当鼠标处于按下并曾经点中按钮的状态下,鼠标松开且在按钮范围外,则触发一次,*/,,
,,,void touchUpOutside (Ref *, pSender,,,控制::EventType 事件),,,
,,,/*,暂时没有发现能用鼠标触发这个事件的操作,看了注释,应该是由其它事件中断按钮事件而触发的,*/,
,,,void touchCancel (Ref *, pSender,,,控制::EventType 事件);
,,,//是否按下按钮
,,,bool isTouch;
私人:
,,,//按钮控件变量
,,,ControlButton *, controlBtn;
};
# endif
event ,枚举,如下:/* *,Kinds of  possible events for 从而control 对象只*/,,,enum class EventType
,,,{
,,,,,,,TOUCH_DOWN ,,,,,,,,,,=, 1, & lt; & lt;, 0,,,,,//, A touch-down event 拷贝,并控制。
,,,,,,,DRAG_INSIDE ,,,,,,,,,=, 1, & lt; & lt,, 1,,,,,//, An event where a finger is dragged inside 从而bounds of 从而控制。
,,,,,,,DRAG_OUTSIDE ,,,,,,,,=, 1, & lt; & lt,, 2,,,,,//, An event where a finger is dragged just outside 从而bounds of 从而控制。
,,,,,,,DRAG_ENTER ,,,,,,,,,,=, 1, & lt; & lt;,,,,,,//, An event where a finger is dragged into 从而bounds of 从而控制。
,,,,,,,DRAG_EXIT ,,,,,,,,,,,=, 1, & lt; & lt;,,,,,,//, An event where a finger is dragged 得到within a control 用outside its 范围。
,,,,,,,TOUCH_UP_INSIDE ,,,,,=, 1, & lt; & lt;,,,,,,//, A touch-up event 拷贝,control where 从而finger is inside 从而bounds of 从而控制。
null
null
null
null