// Called when the node enters the scene tree for the first time. public override void _Ready() { boardScript = (BoardManager)GetTree().GetNodesInGroup("BoardManager")[0]; //como el script esta en el nodo lo busco de esta manera LevelText = (Label)GetTree().GetNodesInGroup("LevelText")[0]; //referencia al texto que muestra el nivel actual FoodText = (Label)GetTree().GetNodesInGroup("FoodText")[0]; //referencia al texto que muestra la comida fondoColorUI = (ColorRect)GetTree().GetNodesInGroup("fondoColorUI")[0]; //referencia al fondo de la UI _SingletonVariables = GetNode <SingletonVariables>("/root/SingletonVariables"); //para acceder al singleton desde el player y cambiar el número del nivel y guardar el puntaje level = _SingletonVariables.level; TimerReiniciarJuego = (Timer)GetTree().GetNodesInGroup("TimerReiniciarJuego")[0]; InitGame();//llamo al script que inicia el nivel lo hago desde escena principal //inicioEscenario = true; }
Wall hitWall;//referencia a la pared que esta chocando // Called when the node enters the scene tree for the first time. public override void _Ready() { //OS.CurrentScreen = 1;//para iniciar el juego en otro monitor y poder trabajar con 2 monitores movementSpeed = 1f / moveTime; //velocidad a la que se movera BoxCollider = GetNode <CollisionShape2D>("CollisionShape2D"); rayo = GetNode <RayCast2D>("RayCast2D"); //referencia al raycast moverConTween = GetNode <Tween>("Tween"); //referencia al nodo tween //rb2D = thi;por ahora voy a evitarla animator = GetNode <AnimationTree>("AnimationTree"); //referencia al animation three _GameManager = (GameManager)GetTree().GetNodesInGroup("GameManager")[0]; playback = (AnimationNodeStateMachinePlayback)GetNode <AnimationTree>("AnimationTree").Get("parameters/playback"); //accedo al nodo animation three y a la propiedad de las maquinas de estado playback.Start("PlayerIdle"); //animación inicial player estatico osea igle _SingletonVariables = GetNode <SingletonVariables>("/root/SingletonVariables"); //para acceder al singleton desde el player y cambiar el número del nivel y guardar el puntaje _FoodText = (Label)GetTree().GetNodesInGroup("FoodText")[0]; //accedo al nodo label que muestra la comida en la pantalla food = _SingletonVariables.food; //la comida inicial del jugador busco desde el game manager _FoodText.Text = "food " + food; //comida del jugador //para procesar el audio y buscar los nodos scavengersFootstepNode = (AudioStreamPlayer)GetTree().GetNodesInGroup("scavengers_footstep")[0]; scavengersFruitNode = (AudioStreamPlayer)GetTree().GetNodesInGroup("scavengers_fruit")[0]; scavengersSodaNode = (AudioStreamPlayer)GetTree().GetNodesInGroup("scavengers_soda")[0]; scavengersDieNode = (AudioStreamPlayer)GetTree().GetNodesInGroup("scavengers_die")[0]; scavengersMusicNode = (AudioStreamPlayer)GetTree().GetNodesInGroup("MusicGame")[0]; }