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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值