void ShootPlayer() { float _playerX = Hitbox.Return().getX(); float deltaX = this.x - _playerX; // float deltaX = _player.position.x - this.x; // float deltaY = _player.position.y - this.y; // float length = Mathf.Sqrt(deltaX * deltaX + deltaY * deltaY); // if(length <= _range) // { if (_cooldown <= 0) { if (deltaX < 1400 && deltaX > -1400) { bullet = new EnemyBullet(this.x, this.y, _shootLeft); _backgroundChanel = _backgroundMusic.Play(); _backgroundChanel.Volume = 0.2f; parent.AddChild(bullet); _cooldown = 60; } } // } }
public void Update() { float playerX = Hitbox.Return().getX(); float deltaX = this.x - playerX; if (deltaX < 1400 && deltaX > -1400) { _step = _step + 1; if (_step > _animDrawsBetweenFrames) { NextFrame(); _step = 0; if (currentFrame == 2) { SetFrame(0); } movement(); } } }