T
tacha
Guest
Hi!
I'm making an Android game and there's a room in which I will have N numbers of plants that can be swapped within each others. For example, I have 10, I select one and I can swap the position with one of the remaining 9; the idea is to be able to select any of the 10 plants and swap them with any of the remaining plants, not just one that can be swapped with the others.
Also, every plant is a different object with their own create, step, alarm, etc. I need to swap different objects that have different functionalities.
I have been trying this with a controller:
/// Create Event
firstSelected = noone;
secondSelected = noone;
/// Global Left Pressed Event
if (firstSelected == noone)
{
firstSelected = instance_position(mouse_x,mouse_y, all);
}
else
{
secondSelected = instance_position(mouse_x,mouse_y, all);
firstSelectedX = firstSelected.x;
firstSelectedY = firstSelected.y;
firstSelected.x = secondSelected.x;
firstSelected.y = secondSelected.y;
secondSelected.x = firstSelectedX;
secondSelected.y = firstSelectedY;
firstSelected = noone;
}
It works, but I can swap the position with every object in the room and I just want to swap between the plants objects. Any idea how to solve this? Thanks in advance!
I'm making an Android game and there's a room in which I will have N numbers of plants that can be swapped within each others. For example, I have 10, I select one and I can swap the position with one of the remaining 9; the idea is to be able to select any of the 10 plants and swap them with any of the remaining plants, not just one that can be swapped with the others.
Also, every plant is a different object with their own create, step, alarm, etc. I need to swap different objects that have different functionalities.
I have been trying this with a controller:
/// Create Event
firstSelected = noone;
secondSelected = noone;
/// Global Left Pressed Event
if (firstSelected == noone)
{
firstSelected = instance_position(mouse_x,mouse_y, all);
}
else
{
secondSelected = instance_position(mouse_x,mouse_y, all);
firstSelectedX = firstSelected.x;
firstSelectedY = firstSelected.y;
firstSelected.x = secondSelected.x;
firstSelected.y = secondSelected.y;
secondSelected.x = firstSelectedX;
secondSelected.y = firstSelectedY;
firstSelected = noone;
}
It works, but I can swap the position with every object in the room and I just want to swap between the plants objects. Any idea how to solve this? Thanks in advance!
Last edited by a moderator: