cocos2dx node使用

 node常用属性:            
1._eventDispatcher:事件派发器,使用它来管理当前节点(Scene, Layer和Sprite)不同事件的分配。 _eventDispatcher有两个添加监听器的方法: 

    // Adds event listener

    

    /** Adds a event listener for a specified event with the priority of scene graph.

     *  @param listener The listener of a specified event.

     *  @param node The priority of the listener is based on the draw order of this node.

     *  @note  The priority of scene graph will be fixed value 0. So the order of listener item

     *          in the vector will be ' <0, scene graph (0 priority), >0'.

     */

    void addEventListenerWithSceneGraphPriority(EventListener* listener, Node* node);

 

    /** Adds a event listener for a specified event with the fixed priority.

     *  @param listener The listener of a specified event.

     *  @param fixedPriority The fixed priority of the listener.

     *  @note A lower priority will be called before the ones that have a higher value.

     *        0 priority is forbidden for fixed priority since it's used for scene graph based priority.

     */

    void addEventListenerWithFixedPriority(EventListener* listener, int fixedPriority);

    事件派发器由事件的优先权来派发事件。 方法一:由node的_localZOrder值的高低派发,值高优先,当这个node被移除时,该监听器也会被移除。 方法二:由整型值的高低派发, 当这个node被移除时,该监听器需要自己手动移除

 
原文地址:https://www.cnblogs.com/liugangBlog/p/6285772.html