문제

I am using this code as a base to create a container, that consists of a number of sprites so I can move them around as one entity. All is working except if i start to pan to early, before the container process is completed. If i do that the container node on top will drag the other sprites after. I want all sprites to be connected and move as connected.

If I wait until the whole process is completed there is no problems meaning a pan is moving the whole container node.

I wonder if someone could guide me how to stop interaction with the selected sprites that should be included in the container until the process is completed?

I have tried '_background.userInteractionEnabled = NO;' as well as adding to the nodes themselves but with no success. I have been trying to use runBlock with the same result.

I need to get 1.) all interaction with the nodes in _selectedNodeArray should be inhibited 2.) run all the code and create the container 3.) enable interaction to the container/node.

Here is the code:

if ([_selectedNodeArray count] > 2) {

        //////CLEAN THE ARRAY//////
        _selectedNodeArray = [[NSArray alloc]initWithArray:[self cleanSelectedNodeArray:_selectedNodeArray]];
        NSLog(@"currentNode:%@ position:%@", _currentNode.name, NSStringFromCGPoint(_currentNode.position));


        SKNode *theSelectedNode = [_background childNodeWithName:_currentNode.name];

        SKAction *pulseCard = [SKAction sequence:@[
                                                  [SKAction playSoundFileNamed:@"beep-7.wav" waitForCompletion:YES],
                                                  [SKAction colorizeWithColor:[SKColor yellowColor] colorBlendFactor:1.0 duration:0.15],
                                                  [SKAction waitForDuration:0.1],
                                                  [SKAction colorizeWithColorBlendFactor:1.0 duration:0.15],
                                                  [SKAction waitForDuration:0.1]
                                                  ]];

        SKAction *sequence = [SKAction sequence:@[
                                                  [SKAction repeatAction:pulseCard count:3],
                                                  [SKAction performSelector:@selector(kickStartContainerMode) onTarget:self]]];


        [theSelectedNode runAction: sequence];
        _isThisPressedAlready = YES;
     }
도움이 되었습니까?

해결책

The problem turned out to be this line:

[SKAction repeatAction:pulseCard count:3],

If the move of the sprite happened before the "count:3" was completed it seems like the container was not 100% packed.

It doesn't solve the real problem but the problem i had in this code.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top