image - Game Maker - Mouse Click image_index Checking -


i have sprite: spr_meteoritelv3, has 2 sub-images index image_index 0 , 1 respectively.

i have these objects: obj_meteoritelv3, obj_tempmeteoritelv3, , obj_score. object obj_meteoritelv3 spawns above random position, random amount, , random sub-image. object obj_tempmeteoritelv3 makes obj_meteoritelv3s spawn. when player clicks on meteorite, program checks value of image_index object.

obj_meteoritelv3 has these events:

create event: change sprite_index spr_meteoritelv3, , start moving downwards.

left-pressed mouse event: destroy self instance, , check image_index: if image_index == 0 score += 5; else score -= 5).

obj_tempmeteoritelv3 has these events:

create event: set alarm 0 3600, set variable exist 1, , set variable add 1.

alarm 0: set variable add 0, , destroy obj_meteoritelv3 instance.

alarm 1: set variable exist 1.

step event: if (exist == 1) then, if (add == 1) create instance of obj_meteoritelv3, set variable exist 0, , set alarm 1 10.

obj_score has these events:

create event: set score 0.

draw event: draw value of score.

the problem is, no matter sub-image meteorite image_index has when clicked, score incremented 5 points. it's else condition isn't working. how can fix this? please explain answer. thanks.

i add images better understanding. link 1. link 2

in obj_meteoritelv3 it's being destroyed before can execute rest of code blocks. move "destroy instance" bottom.

in obj_tempmeteoritelv3 both variables "add" , "exist" not necessary, instead have-

create event-

alarm[0] = 3600

alarm[1] = 10

alarm[0] event-

destroy_instance

alarm[1] event

create_instance of obj_meteoritelv3

alarm[1] = 10


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -