Są dwie opcje. Pierwsza:
//create
way =1;
//event myszki
if (way == 1) {
y += 1;
if (y == 10) way = 0;
} else {
y-=1;
if (y == 0) way = 1;
}
Druga:
//create
result = 1;
//event myszki
result++;
if (result==10) result = -10;
y = abs(result);
Ja to zawsze robię przez jeden nadrzędny obiekt kontroler. Nazwijmy go sobie "oControl".
Teraz u ciebie po kliknięciu będziesz przypisywał do niego ID oMonster.
/// oMonster - STEP
with(instance_nearest(mouse_x, mouse_y, oMonster){ // Musiałem tego użyć, żeby poruszał się objekt, którego klikam
if(mouse_check_button_pressed(vk_left) && collision_ponit(mouse_x, mouse_y, oMonster, true, false)){
animuj = true;
oControl.monster = id
}
}
Trzeba to jeszcze rozwinąć o sprawdzenie, czy tylko jeden może być kliknięty:
/// oControl - CREATE
monster = noone
/// oMonster - STEP
with(instance_nearest(mouse_x, mouse_y, oMonster){ // Musiałem tego użyć, żeby poruszał się objekt, którego klikam
if(mouse_check_button_pressed(vk_left) && oControl.monster==noone && collision_ponit(mouse_x, mouse_y, oMonster, true, false)){
animuj = true;
oControl.monster = id
}
}
Brakuje jeszcze odznaczania. Więc gdzieś musisz ustawiać oControl.monster = noone.
Wyświetlanie oczywiście już nie jest takie jak dałeś, a:
/// oMonster - DRAW
if(oControl.monster == id){
y += swith; // na starcie swith=1
if(y >= 110){ swith = -1; }
else if(y <= 100){ swith = 1; }
}