I'm currently trying to use a UIButton titled "X" as a way to remove a Sprite from the view.
Basically, my code works so that when a Sprite is touched, a message is sent to the delegate (View Controller) that passes the (Sprite *)sprite which has been selected. In this method, I draw a UIButton on top of that sprite. So far, so good.
However, the issue is I now want my UIButton to run a @selector to remove that sprite whenever the button is touched down.
Initially I tried this:
-(void)spriteSelected:(Sprite *)sprite{ //delegate method implementation
[sprite.button addTarget:self action:@selector(removeSprite:sprite) forControlEvents: UIControlEventTouchDown]
}
-(void)removeSprite:(Sprite *)sprite{
[sprite removeFromSuperView];}
However, it seems I can't put arguments into the selector like that. Any ideas on how I can adjust this?
Thanks