Gamua / Sparrow-Framework

The Open Source Game Engine for iOS
http://www.sparrow-framework.org
Other
294 stars 83 forks source link

EXC_BAD_ACCESS code=1 handling SPTouch events #16

Closed mafua closed 11 years ago

mafua commented 11 years ago

I may have found a little casualty in master. I have an SPImage that handles touch events like this:

SPImage *skip = [TextureFactory image:@"skip" forKey:@"main"];
skip.x = _screenWidth - skip.width - 20;
skip.y = _screenHeight - skip.height - 20;
skip.alpha = 0;
__weak SPImage *shapeCopy = skip;
[myself addChild:skip];
[skip fadeTo:1 delay:1 time:1];
[skip addEventListenerForType:SP_EVENT_TYPE_TOUCH block:^(id event) {
    SPTouch *touch = [((SPTouchEvent*)event).touches anyObject];
    if (touch.phase == SPTouchPhaseBegan)
    {
        shapeCopy.color = 0x392281;

        [event stopImmediatePropagation];

        [myself skipIntro];
    }
}];

And my container, a class that extends SPSprite also handles touch events (for swipes, for example):

[myself addEventListener:@selector(onTouchScene:) atObject:self forType:SP_EVENT_TYPE_TOUCH];

Anyways, I get this error 50% of times, and it explodes in SPTouchProcessor.m. I will keep investigating further, but if I use tag v2.0.1, it never happens.

screen shot 2013-10-10 at 2 57 09 pm

PrimaryFeather commented 11 years ago

Thanks for the information! I'll have a look at this next week. I'll keep you posted!

jbernabeu commented 11 years ago

captura de pantalla 2013-10-12 a la s 19 41 59 I have the same issue and I think I know why is going on.

The problem is that we have multi touch enabled (for swipe actions) and we release some objects while there is a finger touching one of them ... so there is no object when the SPTouchProcessor tries to call the event in the object.

I hope this will help.

I tried again with the stable version and works great ...

racarone commented 11 years ago

Since __weak is unavailable in MRC, I'd suggest just having SPTouch retain its target in the same way UITouch retains the target view.

jbernabeu commented 11 years ago

Great, it works !!!! ;-)

racarone, is this going to be in Gamua / Sparrow-Framework or only in Sparrow-S ?????

racarone commented 11 years ago

It will make it into Sparrow soon =)

mafua commented 11 years ago

Nice! =)

PrimaryFeather commented 11 years ago

That should work now -- it's now retained, just as in Sparrow 1.x. Thanks to both of you! Mafuá, please try out if that fixes your issue.

mafua commented 11 years ago

Will do!

Cheers, hcabral