New event-Distribution mechanism _COCO2DX

Source: Internet
Author: User
Tags event listener

In the 2.x processing of events need to use the principal agent (delegate), I believe that the learning of the 2.x touch events, students know that the creation and removal of the process is very cumbersome.

In 3.x, because of the addition of the c++11 feature, the distribution mechanism of the event is managed through the event distributor Eventdispatcher.

The main event listeners are:

> Touch events: Eventlistenertouchonebyone, eventlistenertouchallatonce

> Mouse Response Event: Eventlistenermouse

> Keyboard Response Event: Eventlistenerkeyboard

> Accelerometer Event: eventlisteneracceleration

> Custom Event: Eventlistenercustom

> Physical Impact Events: Eventlistenerphysicscontact

> Game Handle Event: Eventlistenercontroller


Thank

Http://www.cnblogs.com/Richard-Core/p/3892641.html

http://blog.csdn.net/runaying/article/details/16352879



The event Distributor

Event Dispatcher Eventdispatcher, which is used to unify the distribution of all events that manage event listeners.


1, _eventdispatcher

_eventdispatcher is the attribute of node, obtained by Director::getinstance ()->geteventdispatcher ().

_eventdispatcher's work is made up of three parts:

(1) Event Distributor: Eventdispatcher.

(2) Type of event: Eventtouch, Eventkeyboard and so on.

(3) Event listener: Eventlistenertouch, Eventlistenerkeyboard and so on.

The listener implements various triggering logic, distributes the event type by the event distributor in due course, and then invokes the appropriate type of listener.


2. Add/Remove Listeners

Add Listener: addeventlistenerwithscenegraphpriority,

Addeventlistenerwithfixedpriority.

Remove Listener: RemoveEventListener,

Removealleventlisteners.


3. Main function

Contains the listener's add, delete, pause, restore, priority settings, hand-distribute events, and so on. 1, 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.