Cocos2D: SneakyJoystick + Touch Events, problem.
im having some trouble using SneakyJoystick and ccTouchEnded stuff.

What is my goal, use the joystick to walk around and the touches to interact with the surrounding area.

I have two layers,ControlLayer (z:2) and GamePlayLayer (z:1)
Im Using TiledMap for my ground and map.
The Joystick by it self works fine, it is attached to the ControlLayer. I can walk, colide and stuff.

When i add the Touch events to the GamePlayLayer, the touch works, i can click on something on the "ground" and interact with it. BUT my joystick dosent work then, if i run using the touch the joystick just sit there not responsive.

Here is some of my code, if u guys need more, just ask.


Touch methods in the GameplayLayer

<pre>
-(void) registerWithTouchDispatcher
{
   [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self
                                                     priority:0 swallowsTouches:YES];
}

-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
   return YES;
}


-(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event
{
   
    CGPoint touchLocation = [touch locationInView: [touch view]];      
    touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation];
    touchLocation = [self convertToNodeSpace:touchLocation];
    CGPoint tileCoord = [self tileCoordForPosition:touchLocation];
    int tileGid = [meta tileGIDAt:tileCoord];
    if (tileGid) {
        NSDictionary *properties = [tileMap propertiesForGID:tileGid];
        if (properties) {
            NSString *collectable = [properties valueForKey:@"Collectable"];
            if (collectable && [collectable compare:@"True"] == NSOrderedSame) {
                [meta removeTileAt:tileCoord];
                [foreground removeTileAt:tileCoord];
            }
   
        }
    }
}

</pre>

And how my scene is arranged:
<pre>
@implementation SandBoxScene

-(id)init {
    self = [super init];
    if (self!=nil) {
        //Control Layer
        controlLayer = [GameControlLayer node];
        [self addChild:controlLayer z:2 tag:2];
       
        //GamePlayLayer
        GameplayLayer *gameplayLayer = [GameplayLayer node];
        [gameplayLayer connectControlsWithJoystick:[controlLayer leftJoyStick]
                                     andJumpButton:[controlLayer jumpButton]
                                   andAttackButton:[controlLayer attackButton]];
        [self addChild:gameplayLayer z:1 tag:1];
    }
    return self;
}

@end
</pre>

Thanks for the help!
Cocos2D: SneakyJoystick + Touch Events, problem.
===

im having some trouble using SneakyJoystick and ccTouchEnded stuff.

What is my goal, use the joystick to walk around and the touches to interact with the surrounding area.

I have two layers,ControlLayer (z:2) and GamePlayLayer (z:1)
Im Using TiledMap for my ground and map.
The Joystick by it self works fine, it is attached to the ControlLayer. I can walk, colide and stuff.

When i add the Touch events to the GamePlayLayer, the touch works, i can click on something on the "ground" and interact with it. BUT my joystick dosent work then, if i run using the touch the joystick just sit there not responsive.

Here is some of my code, if u guys need more, just ask.


Touch methods in the GameplayLayer

<pre>
-(void) registerWithTouchDispatcher
{
   [[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self
                                                     priority:0 swallowsTouches:YES];
}

-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
   return YES;
}


-(void) ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event
{
   
    CGPoint touchLocation = [touch locationInView: [touch view]];      
    touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation];
    touchLocation = [self convertToNodeSpace:touchLocation];
    CGPoint tileCoord = [self tileCoordForPosition:touchLocation];
    int tileGid = [meta tileGIDAt:tileCoord];
    if (tileGid) {
        NSDictionary *properties = [tileMap propertiesForGID:tileGid];
        if (properties) {
            NSString *collectable = [properties valueForKey:@"Collectable"];
            if (collectable && [collectable compare:@"True"] == NSOrderedSame) {
                [meta removeTileAt:tileCoord];
                [foreground removeTileAt:tileCoord];
            }
   
        }
    }
}

</pre>

And how my scene is arranged:
<pre>
@implementation SandBoxScene

-(id)init {
    self = [super init];
    if (self!=nil) {
        //Control Layer
        controlLayer = [GameControlLayer node];
        [self addChild:controlLayer z:2 tag:2];
       
        //GamePlayLayer
        GameplayLayer *gameplayLayer = [GameplayLayer node];
        [gameplayLayer connectControlsWithJoystick:[controlLayer leftJoyStick]
                                     andJumpButton:[controlLayer jumpButton]
                                   andAttackButton:[controlLayer attackButton]];
        [self addChild:gameplayLayer z:1 tag:1];
    }
    return self;
}

@end
</pre>

Thanks for the help!