• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Why does nothing happen when I left click?

P

prithvidiamond

Guest
Hello,
Below is the code(script) that is executed in the step event.
MY QUESTION IS : Why does nothing happen when I left click?

code:

//step event
if(mouse_check_button(mb_left))
{
with (instance_position(mouse_x, mouse_y, obj_2))
{
if (sprite_index == spr_fr_wm && fruit == 0)
{
points += 1
}
}
}
script_execute(scr_draw_obj1);
script_execute(scr_draw_obj2);

if(mouse_check_button(mb_left))
{
with (instance_position(mouse_x, mouse_y, obj_2))
{
if (sprite_index == spr_fr_sr && fruit == 1)
{
points += 1
}
}
}
script_execute(scr_draw_obj1);
script_execute(scr_draw_obj2);

if(mouse_check_button(mb_left))
{
with (instance_position(mouse_x, mouse_y, obj_2))
{
if (sprite_index == spr_fr_sb && fruit == 2)
{
points += 1
}
}
}
script_execute(scr_draw_obj1);
script_execute(scr_draw_obj2);

if(mouse_check_button(mb_left))
{
with (instance_position(mouse_x, mouse_y, obj_2))
{
if (sprite_index == spr_fr_rs && fruit == 3)
{
points += 1
}
}
}
script_execute(scr_draw_obj1);
script_execute(scr_draw_obj2);


Please help, any suggestions is really appreciated.

prithvidiamond
 

Surgeon_

Symbian Curator
Check if conditions in the "if" statements are ever being fulfilled (use show_message() or a similar function to check).

Other than that, I could use a bit more information in order to help you out: Is "points" a local or a global variable? And what, in fact, is supposed to happen?

Also, I'd be careful with the "with (instance_position(...))" structure because you'll get unpredictable results if there are no instances at that particular position.

-Surgeon_
 
P

prithvidiamond

Guest
If you ask me it looks like it is not being fulfilled because no points are being added but I need that is looks into which sprite is clicking on if a variable is equal to the value.

Please leave your suggestions!

prithvidiamond
 

Surgeon_

Symbian Curator
Note that when you use the "with" statement like that you will add points to obj_2's and not the object calling the script above.

-Surgeon_
 
A

Aura

Guest
If you want to refer to the object calling this code, you can use the other keyword. So it'd be other.points if it's a variable of the object calling this code.
 
Top