public void ShootSpell(CGPoint position) { Cooldown = 100; var vector = new CGVector(position.X - Position.X, position.Y - Position.Y); var spell = ShotSprite.CreateShotAt(Position, SpellType.Enemy); Parent.AddChild(spell); spell.AttackByVector(vector); spell.ZRotation = (nfloat)Math.Atan2(vector.dy, vector.dx); }
public void ShootSpell(CGPoint position) { // Create vector of the movement var vector = new CGVector(position.X - Position.X, position.Y - Position.Y); // Create spell instance place it into the world and force it to attack var spell = ShotSprite.CreateShotAt(Position, SpellType.Hero); Parent.AddChild(spell); spell.AttackByVector(vector); spell.RunAction(SKAction.RepeatActionForever(SKAction.RotateByAngle((nfloat)6.28, 1))); }