task Cutin(obj,text,let Stage){
	PlaySound(CSD~"/SFX/SPELLCARD.wav");
	let alpha=0;
	let x=GetStgFrameWidth-150;
	let objTxt=ObjText_Create;
	ObjText_SetText(objTxt,text);
	ObjText_SetFontSize(objTxt,13);
	ObjText_SetFontColorTop(objTxt,255,255,255);
	if(Stage==1){ ObjText_SetFontColorBottom(objTxt,255,32,32);}
	if(Stage==2){ ObjText_SetFontColorBottom(objTxt,155,40,255);}
	if(Stage==3){ ObjText_SetFontColorBottom(objTxt,255,32,255);}
	ObjText_SetFontBorderType(objTxt,BORDER_FULL);
	ObjText_SetFontBorderColor(objTxt,0,0,0);
	ObjText_SetFontBorderWidth(objTxt,1);
	ObjText_SetHorizontalAlignment(objTxt,ALIGNMENT_LEFT);
	ObjText_SetMaxWidth(objTxt,380);
	Obj_SetRenderPriority(objTxt,0.8);
	ObjRender_SetPosition(objTxt,x,GetStgFrameHeight-200,0);
//	ObjText_SetAutoTransCenter(objTxt,true);
	ObjRender_SetAlpha(objTxt,0);
	
	let path=CSD~"/Texture/reimuhakurei.png";
	let cut=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(cut,path);
	ObjSprite2D_SetSourceRect(cut,0,0,502,493);
    ObjSprite2D_SetDestCenter(cut);
	ObjRender_SetPosition(cut,-128,GetStgFrameHeight/3*1.75,0);
	Obj_SetRenderPriority(cut,0.78);
	ObjRender_SetScaleXYZ(cut,0.5,0.5,0.5);
	TMove;
	TCut;
	TImage;

	let dir=2;
	ascent(x in -4..4){
		ascent(y in -5..5){
			
	if(Stage==1){	SpellAttack(1);}
	if(Stage==2){	SpellAttack(2);}
	if(Stage==3){	SpellAttack(3);}
			dir=-dir;
		}
	}
	task TMove{
		let n=45;
		descent(i in 0..n){
			alpha+=255/n;
			x-=i/n*4.37;
			ObjRender_SetX(objTxt,x);
			ObjRender_SetAlpha(objTxt,alpha);
			yield;
		}
		wait(15);
		n=30;
		let y=GetStgFrameHeight-200;
		ascent(i in 0..n){
			y-=i/n*7.2;
			ObjRender_SetY(objTxt,y);
			yield;
		}
		descent(i in 0..n){
			y-=i/n*7.2;
			ObjRender_SetY(objTxt,y);
			yield;
		}
		while(!Obj_IsDeleted(obj)){yield;}
		let yscale=1;
		loop(45){
			alpha-=(255/45);
			yscale+=(3/45);
			ObjRender_SetAlpha(objTxt,alpha);
			ObjRender_SetScaleXYZ(objTxt,yscale,yscale,1);
			yield;
		}
		Obj_Delete(objTxt);
	}
	task TCut{
		let n=25;
		let cX=-128;
		descent(i in 1..n){
			cX+=i/n*29;
			ObjRender_SetX(cut,cX);
			yield;
		}
		let D=GetDistance(ObjRender_GetX(cut)+(502/3),ObjRender_GetY(cut),GetStgFrameWidth,ObjRender_GetY(cut));
		loop(36){
			cX+=D/36;
			ObjRender_SetX(cut,cX);
			yield;
		}
		n=15;
		let xS=0.5;
		let yS=0.5;
		ascent(i in 0..n){
			xS+=i/n/45;
			yS-=i/n/15;
			ObjRender_SetScaleX(cut,xS);
			ObjRender_SetScaleY(cut,yS);
			yield;
		}
		Obj_Delete(cut);
	}
	task TImage{
		let alpha2=0;
		let scale2=4;
		let yscale2=1;
		let ypos2=ObjRender_GetY(objTxt)-5;
		let objI=ObjPrim_Create(OBJ_SPRITE_2D);
		let pathI;
		if(Stage==1){ pathI = CSD~"/Texture/cut.png";}
		if(Stage==2){ pathI = CSD~"/Texture/cut2.png";}
		if(Stage==3){ pathI = CSD~"/Texture/cut3.png";}
		ObjPrim_SetTexture(objI,pathI);
		ObjSprite2D_SetSourceRect(objI,119,3,383,60);
		ObjSprite2D_SetDestCenter(objI);
		Obj_SetRenderPriority(objI,0.79);
		ObjRender_SetPosition(objI,ObjRender_GetX(objTxt)+125,ObjRender_GetY(objTxt)-3,0);
		ObjRender_SetAlpha(objI,255);
		if(Stage==1){ SetColor(objI,"RED","NORMAL");}
		if(Stage==2){ SetColor(objI,"PURPLE","NORMAL");}
		if(Stage==3){ SetColor(objI,"ROSE","NORMAL");}
		while(!Obj_IsDeleted(obj)){
			ObjRender_SetPosition(objI,ObjRender_GetX(objTxt)+125,ObjRender_GetY(objTxt)-3,0);
			if(GetPlayerY<=60 && alpha2>=100){alpha2-=(255/45);ObjRender_SetAlpha(objI,alpha2);ObjRender_SetAlpha(objTxt,alpha2);}
			if(GetPlayerY>=60 && alpha2<=255){alpha2+=(255/45);ObjRender_SetAlpha(objI,alpha2);ObjRender_SetAlpha(objTxt,alpha2);}
			yield;
		}
		loop(45){
			alpha2-=(255/45);
			yscale2+=(3/45);
			ObjRender_SetAlpha(objI,alpha2);
			ObjRender_SetScaleXYZ(objI,yscale2,yscale2,1);
			yield;
		}
		Obj_Delete(objI);
	}
	
}