Narendrabrsoft / cocos2d-android-1

Automatically exported from code.google.com/p/cocos2d-android-1
0 stars 0 forks source link

CCTouchDispatcher ignoring priority and results. #62

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I noticed this code in the touch dispatcher:

[code]    private void touchesBegan(MotionEvent event) {
        if( dispatchEvents )  {
            for( int ind = 0; ind < touchHandlers.size(); ind++ ) {
                CCTouchHandler handler = touchHandlers.get(ind);
                handler.ccTouchesBegan(event);
//                if( handler.ccTouchesBegan(event) == kEventHandled )
//                    break;
            }
        }
    }
[/code]

From what I understand, there are two things here that seem wrong: First, touch 
delegates should be called in order of their priority (from low to high). The 
priority is ignored here, and delegates are called in the order they were added 
instead. Second, if a touch delegate returns kEventHandled then the touch 
should not be forwarded to elements below (see code commented out).

In my game, I have a layer that's sitting on top of a button, and I want that 
layer to receive all motion events, not the button below it. With the current 
behavior (latest source version from git), I cannot do that because I have no 
control over the flow of touch events.

Original issue reported on code.google.com by enno.reh...@gmail.com on 15 Apr 2011 at 5:32

GoogleCodeExporter commented 8 years ago
Standart delegates should not swallow touches. This piece of code is for them.

Original comment by opengen...@gmail.com on 6 May 2011 at 12:16