Note: I am not currently at a computer that is capable of running Xcode, so I'm going off of memory.
Note 2: If I could comment, I would ask you to include the code located in the addSprite
function. However, due to a lack of reputation, I am unable to do so. You could get a much faster and accurate answer by including that code, since that is the code that creates and adds the sprite.
Answer:
You mention that you are attempting to add the same sprite to the screen - possibly like this:
let sprite = SKSpriteNode(color: UIColor.redColor(), size: CGSizeMake(50,50))
func addSprite() {
addChild(sprite)
}
You can not have the same sprite on the screen multiple times. Instead, each time you want a new sprite to be added to the screen, you have to create a new sprite. In your addSprite
function, your code should create a new sprite, set it's properties, and then add it to the main view, as so:
fun addSprite() {
let sprite = SKSpriteNode(color: UIColor.redColor(), size: CGSizeMake(50,50)) // Creates a new sprite. You can customize this as needed.
addChild(sprite) // Adds newly created sprite to screen.
}
I hope this helps. If you post your code, I could provide an answer more tuned to your question.