Detect click/touch on isometric texture

My solution for such a problem 'right now' is:

  • in your scene get all nodes which are in that position of your click, i.e.

    [myScene nodesAtPoint:[theEvent lactionInNode:myScene]]
    
  • don't forget to check if your not clicking the root of your scene something like that:

    if (![[myScene nodeAtPoint:[theEvent locationInNode:myScene]].name isEqual: @"MyScene"])
    

    then go through the Array of possible nodes and check the alpha of the Texture (NOT myNode.alpha)

  • if the alpha is 0.0f go to the next node of your Array
  • pick the first node which alpha is not 0.0f and return the nodes name
  • this way you can find your node (first) and save it, as the node you need, and kill the array, which you don't need anymore
  • than do what you want with your node
  • btw check if your new node you wish to use is nil after searching for its name. if thats true, just break out of your moveDown method

To get the alpha try this.

Mine looks something like that:

-(void)mouseDown:(NSEvent *)theEvent {
     /* Called when a mouse click occurs */
    if (![[self nodeAtPoint:[theEvent locationInNode:self]].name isEqual: self.name]]) {

        /* find the node you clicked */
        NSArray *clickedNodes = [self nodesAtPoint:[theEvent locationInNode:self]];

        SKNode *clickedNode = [self childNodeWithName:[clickedNodes getClickedCellNode]];

        clickedNodes = nil;

        /* call the mouseDown method of your Node you clicked to to node specific actions */
        if(clickedNode) {
           [clickedNode mouseDown:theEvent];
        }
        /* kill the pointer to your clicked node */
        clickedNode = nil;
    }
}