Legacy GM Check when image_index changes

M

Meowanator

Guest
I need to check whenever a sprite's sub-image changes. This is so I can change the music when the background changes. I have it so the background is dependent on one sprite. My code is shown below with the second part being the music code I started adding.
bkg switch.PNG
Code:
///Backgrounds
background_visible[1] = false;
background_visible[2] = false;
background_visible[3] = false;
background_visible[4] = false;
background_visible[5] = false;
background_visible[obj_selectable_bkg.image_index+1] = true;

obj_display_manager.bw_shader_enabled = background_visible[5];

audio_stop_all();
switch obj_selectable_bkg.image_index{
    case 0: audio_play_sound(snd_vampire_killer,80,true); break;
    case 1: audio_play_sound(snd_vampire_killer,80,true); break;
    case 2: audio_play_sound(snd_stalker,80,true); break;
    case 3: audio_play_sound(snd_wicked_child,80,true); break;
    case 4: audio_play_sound(snd_battle_holy,80,true); break;
    
    default: audio_play_sound(snd_vampire_killer,80,true); break;
}
 

Slyddar

Member
Like most checks of this type, you can do it by storing image_index in a variable in a begin step event, then comparing that variable to the image_index in an end step event. If it's different, it changed that step, and you can then run whatever code is required.
 
Top