• 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!

[SOLVED] Changing a single instance of many

E

Edoran

Guest
Hello,

Basically I have created a playing 'board' that randomly generates out of various objects 'tiles'. I want to be able to rotate a single instance of one of these 'tiles' without it affecting other 'tiles' that are the same object.

My code (probably super inefficient) looks like this:

//in the 'left button' event in obj_rotL (selecting the rotate tool)
global.rotL = true;
cursor_sprite = spr_rotL;

//then in 'step' event in obj_p1 (the object I am trying to rotate)
if global.rotL = true && mouse_check_button(mb_left)
{
if position_meeting(mouse_x,mouse_y,obj_p1)
{
if image_angle = 0
{
image_angle = 270
}
else if image_angle = 90
{
image_angle = 0
}
else if image_angle = 180
{
image_angle = 90
}
else if image_angle = 270
{
image_angle = 180
}
}
}
else{}

//Here I would then set the variable global.rotR = false

So far, when I click on one of the tiles I want to rotate, it rotates all of the tiles across the board that are the same object.

Any help appreciated,

Thanks
 
E

ericbomb

Guest
With this

if position_meeting(mouse_x,mouse_y,obj_p1)

do this instead

if position_meeting(mouse_x,mouse_y,id)

Because of the way position_meeting works every single tile is checking to see if your mouse is connected to any obj_p1, and if it is, they'll all activate.
 
E

Edoran

Guest
Well you've only gone and solved it!

Thanks, seems so simple now....
 
Top