0

I noticed this discussion: Setting up buttons in SKScene And decided to take a shot and use the SKSpriteButton class written by Graf, when creating a buttons in my game scrollers.

When the user taps on one of the buttons, the main object in the game should customized with that button's texture.

When I used UIButton it was very easy to determine which button was tapped (when all triggered the same function):

(IBAction)customizeMainObject: (id)sender; 

Is there a way to replicate the same behavior with Sprite Buttons?

Community
  • 1
  • 1
DocForNoc
  • 346
  • 2
  • 13
  • possible duplicate of [Setting up buttons in SKScene](http://stackoverflow.com/questions/19082202/setting-up-buttons-in-skscene) – Andy Heard Jul 28 '14 at 14:42

1 Answers1

0

You can make a subclass of SKSpriteNode that has a property called texture. In TouchesBegan or TouchesEnded, check to see if any of the sprite buttons were touched.

ex.

if ([self.sprite containsPoint: location]) 
{               
    //set players texture = self.sprite.texture;
}    
meisenman
  • 1,818
  • 1
  • 15
  • 25