let bSpell=false;
let GCSD=GetCurrentScriptDirectory();
let bg1=GCSD~"img/bg1.png";
LoadTexture(bg1);
let bg3=GCSD~"img/bg3.png";
LoadTexture(bg3);

@Initialize{
	TCallBg;
}

@MainLoop{
	let objScene=GetEnemyBossSceneObjectID();
	if(objScene!=ID_INVALID&&ObjEnemyBossScene_GetInfo(objScene,INFO_IS_SPELL)){
		bSpell=true;
	}else{
		bSpell=false;
	}
	yield;
}

task TCallBg{
	while(!Obj_IsDeleted(GetEnemyBossSceneObjectID())){
	if(bSpell==false){
		TNormalBackground;
		}
	while(bSpell==false){ yield; }
	if(bSpell==true){
		TSpellBackground;
		}
	while(bSpell==true){ yield; }
	
}


task TNormalBackground{
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	Obj_SetRenderPriority(obj,0.21);
	ObjPrim_SetTexture(obj,bg3);
	ObjSprite2D_SetSourceRect(obj,0,0,640,720);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,512/640,512/720,1);
	ObjRender_SetX(obj,GetStgFrameWidth()/2);
	ObjRender_SetY(obj,GetStgFrameHeight()/2);
}

task TSpellBackground{
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	Obj_SetRenderPriority(obj,0.21);
	ObjPrim_SetTexture(obj,bg1);
	ObjSprite2D_SetSourceRect(obj,0,0,640,720);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,512/640,512/720,1);
	ObjRender_SetX(obj,GetStgFrameWidth()/2);
	ObjRender_SetY(obj,GetStgFrameHeight()/2);
}
}