我注意到了这个讨论:Setting up buttons in SKScene 并决定在我的游戏滚动条中创建按钮时,使用Graf编写的SKSpriteButton类。
当用户点击其中一个按钮时,游戏中的主要对象应该使用该按钮的纹理进行自定义。
当我使用UIButton时,很容易确定哪个按钮被点击(当所有按钮都被触发时):
(IBAction)customizeMainObject: (id)sender;
有没有办法用Sprite Buttons复制相同的行为?
答案 0 :(得分:0)
您可以创建一个SKSpriteNode的子类,它具有一个名为texture的属性。在TouchesBegan或TouchesEnded中,检查是否有任何精灵按钮被触摸。
离。
if ([self.sprite containsPoint: location])
{
//set players texture = self.sprite.texture;
}