public override void _Ready() { Position2D pos = GetParent().GetNode <Position2D>("Spawn"); currentCheckpoint = pos.GetGlobalPosition(); lifeCount = 4; }
public void Shoot() { PlayerBulletObject bulletObj = (PlayerBulletObject)bullets.Instance(); bulletContainer.AddChild(bulletObj); bulletObj.StartAt(GetRotation(), muzzle.GetGlobalPosition()); shootSound.Play(); }
public override void _Process(float delta) { Node player = GetParent().GetNode("Player"); Position2D spawn = (Position2D)GetNode("Spawn"); if (this.OverlapsBody(player)) { player.Set("currentCheckpoint", spawn.GetGlobalPosition()); } if (spawn.GetGlobalPosition() == (Vector2)player.Get("currentCheckpoint")) { GetNode <Sprite>("Active").SetVisible(true); } else { GetNode <Sprite>("Active").SetVisible(false); } }
public void _on_TimerCoin_timeout() { // GD.Print("Saatnya Spawn Koin"); TimerCoin.Stop(); RigidBody2D SpawnCoin = (RigidBody2D)CoinCollectable.Instance(); GetParent().AddChild(SpawnCoin); Position2D CoinSpawn = (Position2D)GetNode("CoinSpawn"); SpawnCoin.SetPosition(CoinSpawn.GetGlobalPosition()); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { //Connecting the Shoot signal with the on_Player_Shoot handler. GetNode("Player/SalmonWeapon").Connect("shoot", this, nameof(on_Player_Shoot)); Position2D spawn = (Position2D)GetNode("MapScene/Spawn"); RigidBody2D player = (RigidBody2D)GetNode("Player"); player.SetPosition(spawn.GetGlobalPosition()); // Turn off the Menu Music var global = GetNode("/root/Global"); var menuAudio = (AudioStreamPlayer)global.GetNode("MenuAudioStreamPlayer"); menuAudio.Stop(); }