Reputation:
So I have a void method that is working as a death for an enemy. So here is that method.
-(void)enemiesDead {
if (enemy1health <= 0) {
[self slime1DeathAnimation];
enemy1.image = [UIImage imageNamed:@""];
}
if (enemy2health <= 0) {
NSLog(@"2 dead");
}
}
As you can see in the top if method that I am playing an animation and then setting that image to blank. Now what I want to do is just delete the UIImageView "enemy1". Just completely delete it. I'm not using cocos2d or anything like that.
Upvotes: 1
Views: 223
Reputation: 10011
You need to call removeFromSuperView method on enemy1 object and then make it nil in that if conditions instead of making the image value as nil. Like this
[enemy1 removeFromSuperView];
enemy1 = nil;
PS:-
There is a reason why you have to set the value of the object to nil that you have just removed from its super view. If you want to know it than just shout.
Upvotes: 2