-(void)createSprite{
CCSprite *shotV = [CCSprite spriteWithFile:@"green.png"];
[self addChild:shotV z:1];
[shotVArray addObject:shotV];
NSlog(@"%@",shotV);
}
-(void)aSpecialCase{
[self removeChild:[shotVArray lastObject] cleanup:YES];
}
我没有让这个工作。 函数“createSprite”会弹出sprite。 “在aSpecialCase中”我想删除最后创建的精灵。还希望删除它将结束该实例的当前CCSequence。
答案 0 :(得分:1)
-(void)aSpecialCase{
[self removeChild:[shotVArray lastObject] cleanup:YES];
}
这只会从图层中删除精灵..不会将其从数组中删除...
更好的方法是......
-(void)aSpecialCase{
CCSprite *sprite = [pshotVArray lastObject];
[self removeChild:sprite cleanup:YES];
[pshotVArray removeObject:sprite];
}
希望这会有所帮助.. :)