ios - How can I call a method from another swift file in GameViewController? -


i have button have created in storyboard lives on game game screen. has ib action in gameviewcontroller() follows:

   @ibaction func buttonpressed(sender: anyobject) {         gamescene().mycustommethod()     } 

in gamescene lives mycustommethod() spawn enemies, code above doesn't work properly. if add println("button pressed") in ibaction, print out in console mycustommethod won't execute , spawn enemies expected.

can me or explain how resolve issue? thanks

in method, create new gamescene object each time. should create once (at initialization), , call mycustommethod on object.

var gamescene: gamescene!  override func viewdidload() {     gamescene = gamescene() }  @ibaction func buttonpressed(sender: anyobject) {     gamescene.mycustommethod() } 

Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -