Hello! I am quite new to swift development, I've been making games in Lua for the last 8 years and this is my first real venture into a new language.
Right now I'm trying to create a simple Snake game to get familiar with the SpriteKit framework. When using Lua I would place each "class" into it's own file, for example with this game I would have a snake.lua that holds all of the snakes data and functions. I am sure that is a common practice with Swift as well but I'm having trouble figuring out exactly how to use it with SpriteKit. All of the SpriteKit examples I find contain all of their code in one file because their project is so small.
What's the best way to setup a file like Snake.swift? Not the actual functionality of the snake but just the best practice for setting up a class like that to use with spritekit. Right now I have
func loadSnake() {
let snake=SKSpriteNode(imageNamed: "Spaceship")
}
inside of snake.swift, and then I am executing loadSnake() inside of didMove() in GameScene.swift. The big problem that I ran into is that I can't add the snake to the scene because I can't access self.addChild(). I'm sure this isn't even close to what I should be doing but hopefully that gives an idea of what I am trying to accomplish.
TL;DR What's the best way to put a class (like Snake in a snake game) in it's own file?
Sorry I'm super new right now this is probably a super simple question but I'm having trouble finding information on this topic. Thank you in advanced!