I have different rooms in my game with a creation code (such as for spawning the player, enemies, ...) and I wanted to create a new room by duplicating one of the others to save time.
In the new room's creation code I changed the name of the player's object to a different one but when I test the game and this new object is spawned it is "freezed": it doesn't move and the Step Event is completely ignored.
I checked for infinite loops and I tried to put a "show_message("...")" in the Step Event, but nothing appears.
So, I ask if anyone have an idea about this strange behavior?
We will need more information in order to be able to tell what's going on.
Could you try putting the show_message in the create event?
Could you give the object information of the relevant objects?
Could you give the room creation code?
We will need more information in order to be able to tell what's going on.
Could you try putting the show_message in the create event?
Could you give the object information of the relevant objects?
Could you give the room creation code?
Sure! Now I will answer to you:
- 1: I've tried that and it worked, if I put "show_message" in the Create Event it shows up!
- 2: Yes, I will post the object information about the player's object:
Information about object: obj_player_1
Sprite: spr_player
Solid: true
Visible: true
Depth: -2
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:
no_damage = false;
change_on = false;
//PARAMETRI SUL MOVIMENTO
//Velocità di movimento
player_speed = 5;
/*Se il gioco è in pausa, allora si distinguono due casi:
1) Se il giocatore ha appena iniziato la partita, la pausa è sfruttata per BLOCCARE TUTTI I ROBOT e lasciare libero di
muoversi il giocatore per i primi due secondi;
2) Se ci troviamo in pausa vera e propria Zimbli può solo muoversi, ma dato che non sono presenti i tasti di movimento nella
schermata di pausa, il giocatore non può comunque muoversi e abbiamo un'effettiva fase di pausa dal gioco.
*/
if (global.pause) exit;
if(instance_number(obj_robot)>0)
{
//INTERFACCIA ANDROID//
//Movimento del giocatore attraverso il primo joystick
hspeed = vstick_get_xaxis(0)*player_speed;
vspeed = vstick_get_yaxis(0)*player_speed;
//Rotazione del giocatore mediante lo stesso joystick
image_angle = vstick_get_direction(0);
direction = vstick_get_direction(0);
//Rotazione attraverso il secondo joystick
//image_angle = vstick_get_direction(1);
//LIMITI DEL LIVELLO PER IL GIOCATORE
if(x > 1024)
{
x-=5;
}
else if(x<0)
{
x+=5;
}
if(y > 768)
{
y-=5;
}
else if(y < 0)
{
y+=5;
}
//COLLISIONE CON IL ROBOT O CON IL SUO PROIETTILE
if(instance_number(obj_robot)>0)
{
if(obj_robot.visible && no_damage == false)
{
if(place_meeting(x,y,obj_robot))
{
if(no_damage == false)
{
//CONTROLLO DELL'ABILITAZIONE O MENO DEGLI EFFETTI SONORI DI GIOCO
//Si controlla se gli effetti sonori sono stati abilitati o meno nel menù delle opzioni
//controllando l'apposita variabile
//L'effetto sonoro viene riprodotto SOLO se sono stati abilitati nel menù "OPTIONS"
if(global.sound_effects_on == 1)
{
audio_play_sound(snd_hit,9,false);
}
//IL GIOCATORE CAMBIA PIANO ED E' SOTTOPOSTO AI GAS VELENOSI
if(global.floor2_on == true && global.pause == false)
{
if(change_on == false)
{
alarm[1] = global.time_damage;
change_on = true;
}
}
//IL GIOCATORE VUOLE SPARARE
if(keyboard_check_pressed(vk_control) && global.init_pause == false)
{
//CONTROLLO DELL'ABILITAZIONE O MENO DEGLI EFFETTI SONORI DI GIOCO
//Si controlla se gli effetti sonori sono stati abilitati o meno nel menù delle opzioni
//controllando l'apposita variabile
//L'effetto sonoro viene riprodotto SOLO se sono stati abilitati nel menù "OPTIONS"
if(global.sound_effects_on == 1)
{
audio_play_sound(snd_shot,5,false);
}
Collision Event with object obj_shot2:
execute code:
if(no_damage == false)
{
//Il giocatore ha perso vita e quindi NON può ottenere la medaglia BULLETPROOF
global.bulletproof_active = false;
//CONTROLLO DELL'ABILITAZIONE O MENO DEGLI EFFETTI SONORI DI GIOCO
//Si controlla se gli effetti sonori sono stati abilitati o meno nel menù delle opzioni
//controllando l'apposita variabile
//L'effetto sonoro viene riprodotto SOLO se sono stati abilitati nel menù "OPTIONS"
if(global.sound_effects_on == 1)
{
audio_play_sound(snd_hit,9,false);
}
I posted the part about the player's object which, maybe, is causing the problem.
The creation code of the room generates a matrix of panels which will define the "ground" of the level and then the enemies and the player are placed in random positions.
Is there an active instance of type obj_player in the room?
And are you aware that you've checked the box of the code in the step event of obj_player_1
to execute for all instances of type obj_player, rather than execute it by the current instance?
Is there an active instance of type obj_player in the room?
And are you aware that you've checked the box of the code in the step event of obj_player_1
to execute for all instances of type obj_player, rather than execute it by the current instance?
No, there aren't active instances of type obj_player in the room and I named the new object "obj_player_1" only to avoid confusion.
Sorry for my question, but I never noticed that "execute for all obj_player" in the Step Event and I want to execute it only for the current instance, maybe is connected to the fact that I duplicated the object "obj_player" in order to make a new one "obj_player_1"?