is this a bug in EAGLView?

is this a bug in EAGLView?
0.0 0


Here is the implementation of touchesBegan:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    cocos2d::NSSet set;
    cocos2d::CCTouch *pTouch;

    for (UITouch *touch in touches) {
        NSNumber *index = (NSNumber*)CFDictionaryGetValue(touchesIntergerDict, touch);
        int unUsedIndex = 0;

        // it is a new touch
        if (! index) {
            unUsedIndex = [self getUnUsedIndex];

            // The touches is more than MAX_TOUCHES ?
            if (unUsedIndex == -1) {

            pTouch = s_pTouches[unUsedIndex] = new cocos2d::CCTouch();

        float x = [touch locationInView: [touch view]].x;
        float y = [touch locationInView: [touch view]].y;
        pTouch->SetTouchInfo(0, x, y);

        CFDictionaryAddValue(touchesIntergerDict, touch, [NSNumber numberWithInt:unUsedIndex]);



CFDictionaryAddValue is always called with “unUsedIndex” which can be 0 if index is not 0. I am not sure this is intended or not.


The value of index has not meaning.


I believe the function need some cleaning work. If the index is meaningless, why not remove it?

If you look at the code, the variable pTouch is only initialized inside the “if (! index) {…}” block. The means if “index” is not 0, pTouch will not be initialized.


Yes, the index should be removed. It is an issue left over by history.


Hey guys.

I just updated to 0.8.1…… (it’s the same code as before). And i don’t receive multitouch events (iphone). Does not matter how many fingers am i swiping - everytimes i get only 1 touch? Am I missing something?


Have you enabled multitouch?
Which may look like:
[__glView setMultipleTouchEnabled:YES];


@Jirka Fajfr
I just run the TouchesTest of tests, control two white blocks simultaneously by 2 fingers.
You can reference to these sources in tests/TouchesTest folder.


Yep… that was the problem… already figured it out. But thanks…