示例#1
0
void RegionLoad::DefineActors()
{
	//Creates a list with actors that intercept the region
	regionActors.Clear();

	KrVector2T< GlFixed > screen, axis;
	Axis *pAxis = GameControl::Get()->GetAxis();
	
	//Get region bounds (Solve the bug "Game behavior differ based on editor grid position when uses regions", ALPHA_1_1_4.ged)
	getImage()->CalcTransform();
	KrRect rectRegion = getImage()->Bounds();
	rectRegion.Translate(-rectRegion.xmin, -rectRegion.ymin);
	
	//To axis coordinate (Solve the bug "Game behavior differ based on editor grid position when uses regions", ALPHA_1_1_4.ged)
	getImage()->ObjectToScreen(0, 0, &screen);
	pAxis->getImage()->ScreenToObject( screen.x.ToInt(), screen.y.ToInt(), &axis );
	rectRegion.Translate(axis.x.ToInt(), axis.y.ToInt());


	MapActorIterator it(mapActors);
	for(it.Begin(); !it.Done(); it.Next())
	{
		ListActor *listActor = it.Value();
		for(int il = 0; il < listActor->Count(); il++)
		{
			Actor *actor = (*listActor)[il];			

			if( actor->EditMode() && 
				!actor->isRegion() &&
				!actor->isView() &&
				actor != pAxis
				)
			{
				//Get actor bounds (Solve the bug "Game behavior differ based on editor grid position when uses regions", ALPHA_1_1_4.ged, abuse2.ged)
				actor->getImage()->CalcCompositeTransform();
				KrRect rectActor = actor->Bounds();

				if(actor->getTextActor() && !rectActor.IsValid())
				{
					//Solve the bug "Text actors aren't load after use the LoadGame function without Activation Regions"
					engine->Tree()->Walk(actor->getImage(), true, true);
					rectActor = actor->Bounds();
				}

				if(actor->getTile() && !rectActor.IsValid())
				{
					//Solve the bug "Text actors aren't load after use the LoadGame function without Activation Regions"
					engine->Tree()->Walk(actor->getImage(), true, true);
					rectActor = actor->Bounds();
				}


				rectActor.Translate(-rectActor.xmin, -rectActor.ymin);

				
				//To axis coordinate (Solve the bug "Game behavior differ based on editor grid position when uses regions", ALPHA_1_1_4.ged, abuse2.ged)
				actor->getImage()->ObjectToScreen(0, 0, &screen);
				pAxis->getImage()->ScreenToObject( screen.x.ToInt(), screen.y.ToInt(), &axis );
				rectActor.Translate(axis.x.ToInt(), axis.y.ToInt());

				if(rectActor.IsValid() && rectRegion.Intersect(rectActor))
				{
					regionActors.Add(actor->getCloneName(), 1); 
				}
			}
		}
	}

	viewPosAnt.Set(-123, 456, 0, 0);
	bRegionInView = false;
}