Ok, this method works for both sharing and or having an independent lifebar.
You should create a simple enemy object using ObjEnemy_Create(OBJ_ENEMY); assign animations, and stuff and use ObjEnemy_Regist(the id of the enemy); to initialize it.
That is pretty much it, the rest is just transferring from one single to another. Now there are two ways of doing this, one way (what I prefer to do) is to pass the second boss's object id to commondata, and then get that id back in the next single and continue controlling the second boss. Method 2 is similar to method 1 but instead of object id, you pass in the position of the second boss.
Method 1
You might not have this depending on how you update dnh, as one of the updates replaces this task for an if statement in the MainLoop. The logic however, is mostly the same.
task TEnd()
{
while(main boss has health){yield;}
Obj_Delete(main boss);
//
SetcommonData("Boss 2 object",boss2);
CloseScript(GetOwnScriptID);
}
Next Single....
@Initialize()
{
boss2 = GetCommonData("Boss 2 object",ID_INVALID); // if this does not exist, then the function will substitute with a different value, in this case, I choose ID_INVALID constant or -1.
}
Method2
task TEnd()
{
while(main boss has health){yield;}
Obj_Delete(main boss);
//This time we're saving the boss's position to an array and passing that array.
SetcommonData("Boss 2 Position",[ObjMove_GetX(boss2),ObjMove_GetY(boss2)]);
Obj_Delete(boss2);
CloseScript(GetOwnScriptID);
}
Next Single....
@Initialize()
{
// same as before, if the commondata doesn't exist, use a default value.
let position = GetCommonData("Boss 2 Position",[0,0]);
ObjMove_SetPosition(boss2,position[0],position[1]);
}
Any other questions (or something isn't clear), feel free to PM me.