B
Blaize
Guest
Hi guys, I have a turn-based tactics game in the works, and I am programming in the unit select function.
Units are created at the start of the level with this code:
At the moment, it simply finds spawn points in the scene and spawns the base Unit object into the scene. The units themselves store their id into the corresponding movement node's Occupant variable (the nodes are empty objects with no other code except for Occupant). The names are just bActor for now.
Now, in the draw event, I have the sprite drawing it's own id to help me determine who's who for now.
Everything works up to this point. The two bActors are showing their own ids as expected. In this case, I have one as 100805 and 100806.
The current system as it is stores the id of the selected unit into a global variable (global.SelectedActor).
However, when I click either one of them with this code:
Regardless of which actor I click on, it will always return the id of 100805. I have a feeling that _obj is returning only the first instance, so how can I return just the occupant's id?
Would appreciate any insight you might have.
Units are created at the start of the level with this code:
Code:
for (i=0;i<instance_number(cSpawnPoint);i++)
{
instance_create_depth(instance_find(cSpawnPoint,i).x,instance_find(cSpawnPoint,i).y,0,bActor);
}
Code:
cMap.Map[@ PositionX div CELL,PositionY div CELL].Occupant = id;
Everything works up to this point. The two bActors are showing their own ids as expected. In this case, I have one as 100805 and 100806.
The current system as it is stores the id of the selected unit into a global variable (global.SelectedActor).
However, when I click either one of them with this code:
Code:
var _x = argument[0];
var _y = argument[1];
var _obj = argument[2];
if (cMap.Map[@ _x,_y].Occupant!=noone)
return _obj.id;
else
return noone;
Would appreciate any insight you might have.