I have this sprite: spr_meteoriteLv3
, which has two sub-images with index image_index
0 and 1 respectively.
I have these objects: obj_meteoriteLv3
, obj_tempMeteoriteLv3
, and obj_score
. Object obj_meteoriteLv3
spawns from above with random position, random amount, and random sub-image. Object obj_tempMeteoriteLv3
makes obj_meteoriteLv3
s spawn. When player clicks on a meteorite, the program checks the value of image_index
for that object.
obj_meteoriteLv3
has these events:
Create Event: change sprite_index
into spr_meteoriteLv3
, and start moving downwards.
Left-pressed Mouse Event: destroy the self
instance, and check image_index
: if image_index == 0
then score += 5
; else score -= 5
).
obj_tempMeteoriteLv3
has these events:
Create Event: set Alarm 0 to 3600, set variable exist
to 1, and set variable add
to 1.
Alarm 0: set variable add
to 0, and destroy the obj_meteoriteLv3
instance.
Alarm 1: set variable exist
to 1.
Step Event: if (exist == 1)
then, if (add == 1)
then create instance of obj_meteoriteLv3
, set variable exist
to 0, and set Alarm 1 to 10.
obj_score
has these events:
Create Event: set score
to 0.
Draw Event: draw the value of score
.
The problem is, no matter which sub-image the meteorite image_index
has when clicked, the score will always be incremented by 5 points. It's like the else
condition isn't working. How can I fix this? Please explain your answer. Thanks.