Note that there are some explanatory texts on larger screens.

plurals
  1. POccTouchBegan doesnt work-iOS
    primarykey
    data
    text
    <pre><code>- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event { if (_nextProjectile != nil) return; CGPoint location = [touch locationInView:[touch view]]; location = [[CCDirector sharedDirector] convertToGL:location]; [[SimpleAudioEngine sharedEngine] playEffect:@"pew-pew-lei.caf"]; CGSize winSize = [[CCDirector sharedDirector] winSize]; CGRect rect = CGRectMake(imgArrow.position.x, imgArrow.position.y,imgArrow.contentSize.width, imgArrow.contentSize.height); if(CGRectContainsPoint(rect, location)) { **_nextProjectile = [[CCSprite spriteWithFile:@"newarrow.png"]retain]; _nextProjectile.position = ccp(430,190);** [imgArrow runAction:[CCSequence actions: [CCRotateTo actionWithDuration:0 angle:0], [CCCallFunc actionWithTarget:self selector:@selector(finishShoot)], nil]]; [blankBow setVisible:true]; [imgArrow setVisible:false]; [walkAnimFrames addObject: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: [NSString stringWithFormat:@"bow1.png", 0]]]; [walkAnimFrames addObject: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: [NSString stringWithFormat:@"bow2.png", 1]]]; [walkAnimFrames addObject: [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: [NSString stringWithFormat:@"bow3.png", 2]]]; walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.2f]; self.walkAction = [CCRepeatForever actionWithAction: [CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]]; self.walkAction.tag = 1; [blankBow runAction:_walkAction]; CCSprite *sprite = blankBow; CCCallBlock *block = [CCCallBlock actionWithBlock:^{ [sprite stopActionByTag:1]; }]; CCDelayTime *time = [CCDelayTime actionWithDuration:0.3]; [sprite runAction:[CCSequence actions:time, block, nil]]; if(flagmultitouch == TRUE) { id actionMove = [CCMoveTo actionWithDuration:1.5 position:ccp(-48,160)]; id actionMoveDone = [CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)]; [_nextProjectile runAction:[CCSequence actions:actionMove, actionMoveDone, nil]]; flagmultitouch = FALSE; } if(_nextProjectile !=nil) _nextProjectile.tag = 2; } else { } return YES; } </code></pre> <p>Problem is with</p> <p><strong>_nextProjectile = [[CCSprite spriteWithFile:@"newarrow.png"]retain]; _nextProjectile.position = ccp(430,190);</strong></p> <p>when i am initializing __nextProjectile in init method ccTouchBegan method doesn't work.. and by puting <strong>_nextProjectile = [[CCSprite spriteWithFile:@"newarrow.png"]retain]; _nextProjectile.position = ccp(430,190);</strong> in ccTouchBegan it initialize every time when Touch performs. any help ?!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload