I need help with coming up with ways to make to make the newly spawned enemy ships all shoot bullets. The problem is that I don't actually know how I am going to do that. I tried using a variable timer but, it only shoots one straight line and I can't really control the location it spawns at.
Game Picture: There are more enemies spawning What I Tried:
var EnemyTimer = Foundation.Timer.scheduledTimer(timeInterval: 0.3, target: self, selector: #selector(GameScene.spawnBullet3), userInfo: nil, repeats: true)
Also Tried:
}
func spawnBullet3(){
let Bullet = SKSpriteNode(imageNamed: "eBullet.png")
Bullet.setScale(1)
Bullet.zPosition = -1
Bullet.position = CGPoint(x: enemy.position.x, y: enemy.position.y)
let action = SKAction.moveTo(y: self.size.height + 100, duration: 0.5)
let actionDone = SKAction.removeFromParent()
Bullet.run(SKAction.sequence([action, actionDone]))
Bullet.physicsBody = SKPhysicsBody(rectangleOf: Bullet.size)
Bullet.physicsBody?.categoryBitMask = PhysicsCategories.Bullet
Bullet.physicsBody!.collisionBitMask = PhysicsCategories.None
Bullet.physicsBody?.contactTestBitMask = PhysicsCategories.Enemy
Bullet.physicsBody?.affectedByGravity = true
Bullet.physicsBody?.isDynamic = false
self.addChild(Bullet)
}