0

I'm trying to rotate a SKSpriteNode based on pan gesture. I figured out the only way to detect pan is to insert small code in the GameViewController.swift. To rotate the sprite on pan, I must call for a rotate function in my scene file. I tried doing PlayScene.rotateTommyLeft() but it gives me error saying Missing argument for parameter #1 in call which is weird cause the function rotateTommyLeft shouldn't require a parameter. I'm posting it below.

func rotateTommyLeft()
{
    tommy.zRotation--
}
Sam
  • 1,130
  • 12
  • 36
  • Probably you declared `rotateTommyLeft` twice? (And you meant `rotateTommyRight`the second time?) – idmean Aug 27 '14 at 22:07
  • Nope. Thats not the case. However, I do seem to notice some strange parameter input required when typing the function. I took a screenshot. [link](http://i.imgur.com/CQ8Xk4u.png) – Sam Aug 27 '14 at 22:09
  • Looks like the method is recognized as function. Did you tried cleaning and rebuilding? – idmean Aug 27 '14 at 22:10
  • Thanks but that doesn't do anything. The projects cleans but I get the same error when rebuilding. – Sam Aug 27 '14 at 22:13
  • possible duplicate of [Missing argument for parameter #1 in call error for function with no params. Swift](http://stackoverflow.com/questions/25435928/missing-argument-for-parameter-1-in-call-error-for-function-with-no-params-swi) – idmean Aug 27 '14 at 22:19
  • Thank you for your help and the question is solved now. – Sam Aug 27 '14 at 22:23

1 Answers1

2

The problem is because you are calling

PlayScene.rotateTommyLeft()

where PlayScene is a class, not an instance

See a similar question and answer here: Missing argument for parameter #1 in call error for function with no params. Swift

Community
  • 1
  • 1
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
  • Thank you for answering me. To clarify, I changed `PlayScene.rotateTommyLeft()` to `PlayScene().rotateTommyLeft()` and it started working. – Sam Aug 27 '14 at 22:22