In my previous app (single view application) i used touch down and touch up inside IBActions for buttons in my game. However in a SpriteKit game you have to completely create the scene and i am having a hard time coding my touchesBegan
method.
Here is my basic movement method/function:
func heroMovementLeft () {
hero.position = CGPointMake(hero.position.x - 0.5,hero.position.y);
}
here is my Left arrow node, i would like the HeroMovementLeft method to be called upon touching the LeftArrow
func LeftArrow () {
let LeftArrow = SKSpriteNode(imageNamed: "Left Arrow.png")
LeftArrow.position = CGPointMake(30, 30)
self.addChild(LeftArrow)
}
Here's where I am at right now for coding the touchesBegan
method
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
/* Called when a touch begins */
for touch in touches {
}
}
Do I create an if statement? Do I make touch a variable? What do I need to write in my touches began method so that my hero will move when left arrow is touched. I have looked all over online and cannot find an answer to this question, please help.