cocos2d-X 节点(UIInputManager.h)API

本文来自http://blog.csdn.net/runaying ,引用必须注明出处!

cocos2d-X 节点(UIInputManager.h)API

温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记

注册 widget input manager

/////cocos2d-x-3.0alpha0/extensions/CocoStudio/GUI/System
// 注册 widget 到 input manager

#ifndef __UIINPUTMANAGER_H__
#define __UIINPUTMANAGER_H__

#include "cocos2d.h"
#include "../Layouts/Layout.h"

NS_CC_EXT_BEGIN

class UIInputManager
{
public:
    /**
     * Default constructor
     */
    UIInputManager();
    
    /**
     * Default destructor
     */
    ~UIInputManager();
    
    /**
     * 注册一个 widget 到 input manager.
     *
     * @param widget    registed widget can be touched.         //注册的 widget 可以被触摸
     */
    void registWidget(UIWidget* widget);
    
    /**
     * 从 input manager 移除一个已经注册的 widget.
     *
     * @param widget    widget which will be removed.
     */
    void removeManageredWidget(UIWidget* widget);
    
    /** 调用他的  "onTouchBegan"方法, 查找被选择的widget
     *
     *
     * @param touch point.
     *
     * @return true that find a widget selected, false otherwise.
     */
    bool checkEventWidget(const Point &touchPoint);
    
    
    void update(float dt);
    bool onTouchBegan(Touch* touch);
    void onTouchMoved(Touch* touch);
    void onTouchEnd(Touch* touch);
    void onTouchCancelled(Touch* touch);
    
    void setRootWidget(UIWidget* root);
    UIWidget* getRootWidget();
    void addCheckedDoubleClickWidget(UIWidget* widget);
protected:
    bool checkTouchEvent(UIWidget* root, const Point& touchPoint);
protected:
    Array* _manageredWidget;
    Array* _selectedWidgets;
    Point _touchBeganedPoint;
    Point _touchMovedPoint;
    Point _touchEndedPoint;
    Point _touchCanceledPoint;
    bool _touchDown;
    float _longClickTime;
    float _longClickRecordTime;
    Array* _checkedDoubleClickWidget;
    UIWidget* _rootWidget;
};

NS_CC_EXT_END

#endif /* defined(__CocoGUI__UIInputManager__) */


你可能感兴趣的:(api,cocos2d,cocos2dx,cocos2d-x)