我照着教程来写的,不过自己增加了一些东西就有问题,以下是代码
-(void)addTarget{
CCSprite *target=;
…略…
//Create the actions;
id actionMove=;
id actionMoveDone=;
];
}
-(void)gameLogic:(ccTime)dt{
;
}
-(void)spriteMoveFinished:(id)sender{
CCSprite *sprite=(CCSprite *)sender;
if (sprite.tag==1) {
;
;//报错 非法访问
;
;
_projectilesDestroyed = 0;
}
else if(sprite.tag == 2) {
;
}
;
}
-(id) init
{
…略…
_resultLabel = ;
; //不报错,能正常设置访问
_resultLabel.color =ccc3(255,255,255);
_resultLabel.position = ccp(winSize.width/2,winSize.height/2);
;
.....略...
}
return self;
}
_resultLabel是一个属性变量,我在init里可以用
; //不报错,能正常设置访问
但是在spriteMoveFinished函数里就是不行,一访问就报非法访问,
是否我写的有问题呢?还是说不支持在定时器中这样子访问,我跟了一下
_resultLabel 的地址都是对的,