let point = 0;

task manageSprite{
		let f2 = 0;
		let ycor = [0,0];
		if(point == 1){
		ycor = [196,284];
		}
		else if(point == -1){
		ycor = [98,196];
		}
		while(f2<=24){
		if(f2<8){ObjSprite2D_SetSourceRect(objBoss, 0, ycor[0], 64, ycor[1]);}
		if(f2>=8 && f2<16){ObjSprite2D_SetSourceRect(objBoss, 64, ycor[0], 128, ycor[1]);}
		if(f2>=16 && f2<24){ObjSprite2D_SetSourceRect(objBoss, 128, ycor[0], 192, ycor[1]);}
		if(f2>=24){ObjSprite2D_SetSourceRect(objBoss, 192, ycor[0], 256, ycor[1]);}
		f2++;
		yield;
		}
		while(ObjMove_GetSpeed(objBoss) > 3){
		yield;
		}
		while(f2>=0){
		if(f2<8){ObjSprite2D_SetSourceRect(objBoss, 0, ycor[0], 64, ycor[1]);}
		if(f2>=8 && f2<16){ObjSprite2D_SetSourceRect(objBoss, 64, ycor[0], 128, ycor[1]);}
		if(f2>=16 && f2<24){ObjSprite2D_SetSourceRect(objBoss, 128, ycor[0], 192, ycor[1]);}
		if(f2>=24){ObjSprite2D_SetSourceRect(objBoss, 192, ycor[0], 256, ycor[1]);}
		f2-= 2;
		yield;
		}

	}

task manageSprite2{
		let f2 = 0;
		let ycor = [0,0];
		ycor = [98,196];
		while(f2<=24){
		if(f2<8){ObjSprite2D_SetSourceRect(objBoss, 0, ycor[0], 64, ycor[1]);}
		if(f2>=8 && f2<16){ObjSprite2D_SetSourceRect(objBoss, 64, ycor[0], 128, ycor[1]);}
		if(f2>=16 && f2<24){ObjSprite2D_SetSourceRect(objBoss, 128, ycor[0], 192, ycor[1]);}
		if(f2>=24){ObjSprite2D_SetSourceRect(objBoss, 192, ycor[0], 256, ycor[1]);}
		f2++;
		yield;
		}
		while(ObjMove_GetSpeed(objBoss) > 3){
		yield;
		}
		while(f2>=0){
		if(f2<8){ObjSprite2D_SetSourceRect(objBoss, 0, ycor[0], 64, ycor[1]);}
		if(f2>=8 && f2<16){ObjSprite2D_SetSourceRect(objBoss, 64, ycor[0], 128, ycor[1]);}
		if(f2>=16 && f2<24){ObjSprite2D_SetSourceRect(objBoss, 128, ycor[0], 192, ycor[1]);}
		if(f2>=24){ObjSprite2D_SetSourceRect(objBoss, 192, ycor[0], 256, ycor[1]);}
		f2-= 2;
		yield;
		}

	}

task attack(time){
	let f = -32;
	idle = false;
	while(f<64){
	if(f<8){ObjSprite2D_SetSourceRect(objBoss, 256, 0, 320, 96);}
	if(f>=8 && f<16){ObjSprite2D_SetSourceRect(objBoss, 320, 0, 384, 96);}
	if(f>=16 && f<24){ObjSprite2D_SetSourceRect(objBoss, 384, 0, 448, 96);}
	if(f>=24 && f < 32){ObjSprite2D_SetSourceRect(objBoss, 448, 0, 512, 96);}
	if(f>=32 && f<40){ObjSprite2D_SetSourceRect(objBoss, 320, 105, 384, 250);}
	if(f>=40 && f<48){ObjSprite2D_SetSourceRect(objBoss, 320, 105, 384, 250);}
	if(f>=48 && f<56){ObjSprite2D_SetSourceRect(objBoss, 384, 105, 448, 250);}
	if(f>=56){ObjSprite2D_SetSourceRect(objBoss, 448, 105, 512, 250);}
	f+= 2;
	yield;
	}
	wait(time);
	idle = true;
	}

task action(b){
	while(b==1){
	ObjSprite2D_SetSourceRect(objBoss, 0, 196, 64, 284);
	yield;
	}
	}

task magiccircle(boss,size,type){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/eff.png";
	let spin = 0;
	let s = 0;
	LoadTexture(img);
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,128,80,256,208);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,size,size,size);
	ObjRender_SetAlpha(obj,192);
	while(!Obj_IsDeleted(boss)){
	spin += 3;
	ObjRender_SetAngleXYZ(obj,0,0,-spin*2);
	ObjRender_SetPosition(obj,ObjMove_GetX(boss),ObjMove_GetY(boss),0);
	if(type==true){
	ObjRender_SetScaleXYZ(obj,size+0.2*sin(spin),size+0.2*sin(spin),0);
	}
	ObjMove_SetPosition(obj,GetEnemyX,GetEnemyY);
	yield;
	}
	Obj_Delete(obj);
	}

task Cutin(name,text,textwidth){ // by Fonduemaster
	let alpha=0;
	let scale=4;
	let yscale=1;
	let objTxt=ObjText_Create;
	ObjText_SetText(objTxt,text);
	ObjText_SetFontSize(objTxt,textwidth);
	ObjText_SetFontColorTop(objTxt,255,255,255);
	ObjText_SetFontColorBottom(objTxt,128,128,255);
	ObjText_SetFontBorderType(objTxt,BORDER_FULL);
	ObjText_SetFontBorderColor(objTxt,0,0,200);
	ObjText_SetFontBorderWidth(objTxt,1);
	ObjText_SetHorizontalAlignment(objTxt,ALIGNMENT_RIGHT);
	ObjText_SetMaxWidth(objTxt,380);
	Obj_SetRenderPriority(objTxt,0.8);
	ObjRender_SetPosition(objTxt,GetStgFrameWidth-385,GetStgFrameHeight-150,0);
	ObjText_SetAutoTransCenter(objTxt,true);
	
	let path;
	if(name=="Futo"){path=GCSD~"img/futo.png";}
	if(name=="Miko"){path=GCSD~"img/miko.png";}
	let cut=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(cut,path);
  	if(name=="Futo"){ObjSprite2D_SetSourceRect(cut,0,0,430,448);}
	if(name=="Miko"){ObjSprite2D_SetSourceRect(cut,0,0,263,480);}
	ObjRender_SetScaleXYZ(cut,0.9,0.9,0.9);
  	ObjSprite2D_SetDestCenter(cut);
	ObjRender_SetPosition(cut,416,120,0);
	Obj_SetRenderPriority(cut,0.50);
	TScale;
	TCut;
	task TScale{
	loop(20){
		alpha+=12.75;
		scale-=0.15;
		ObjRender_SetAlpha(objTxt,alpha);
		ObjRender_SetScaleXYZ(objTxt,scale,scale,1);
		yield;
	}
	wait(55);
	loop(20){
		yscale-=0.05;
		ObjRender_SetScaleXYZ(objTxt,1,yscale,1);
		yield;
	}
	wait(5);
	ObjRender_SetPosition(objTxt,GetStgFrameWidth-385,GetStgFrameHeight-425,0);
	loop(20){
		yscale+=0.05;
		ObjRender_SetScaleXYZ(objTxt,1,yscale,1);
		yield;
	}
	while(!Obj_IsDeleted(objBoss)){yield;}
		loop(20){
			alpha-=12.75;
			yscale+=0.05;
			ObjRender_SetAlpha(objTxt,alpha);
			ObjRender_SetScaleXYZ(objTxt,yscale,yscale,1);
			yield;
		}
		Obj_Delete(objTxt);
	}
	task TCut{
		let speed=1;
		ObjRender_SetAlpha(cut,0);
		ascent(i in 0..20){
			ObjRender_SetX(cut,ObjRender_GetX(cut)-speed*9);
			ObjRender_SetY(cut,ObjRender_GetY(cut)+speed*4);
			ObjRender_SetAlpha(cut,i*255/20);
			yield;
			}
		loop(80){
		ObjRender_SetX(cut,ObjRender_GetX(cut)-speed); 
		ObjRender_SetY(cut,ObjRender_GetY(cut)+speed/2); 
		yield;
		}
		descent(i in 0..20){
			ObjRender_SetX(cut,ObjRender_GetX(cut)-speed*9);
			ObjRender_SetY(cut,ObjRender_GetY(cut)+speed*4);
			ObjRender_SetAlpha(cut,i*255/20);
			yield;
			}
		Obj_Delete(cut);
		}
}

task boat(type){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/boat.png";
	let c = 0;
	let acc = 8;
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,188,92);
	ObjRender_SetPosition(obj,150+50*sin(225),0,0);
	ObjSprite2D_SetDestCenter(obj);
	if(type==0){
	 while(!Obj_IsDeleted(objBoss)){
	 ObjRender_SetPosition(obj,GetEnemyX,GetEnemyY+40,0);
	 ObjRender_SetAngleXYZ(obj,0,0,0+5*sin(c)+5);
	 c++;
	 yield;
	 }
	 Obj_Delete(obj);
	 }
	
	if(type==1){
	 while(c<300){
	 ObjRender_SetPosition(obj,GetEnemyX+300-c,150-50*sin(225)+40,0);
	 ObjRender_SetAngleXYZ(obj,0,0,0+5*sin(c)+5);
	 c+= acc;
  	 acc -= 0.1;
	 yield;
	 }
	 wait(60);
	 while(!Obj_IsDeleted(objBoss)){
	 ObjRender_SetPosition(obj,GetEnemyX,GetEnemyY+50,0);
	 ObjRender_SetAngleXYZ(obj,0,0,0+5*sin(c)+5);
	 c++;
	 yield;
	 }
	 Obj_Delete(obj);
	}
	}

function TCharge01(x,y,size,frame,r,g,b){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/charge.png";
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,128);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,x,y,0);
	ObjRender_SetAlpha(obj,0);
	ObjRender_SetScaleXYZ(obj,size,size,0);
	ObjRender_SetColor(obj,r,g,b);
	TAlpha;
	TShrink;
	return obj;
	task TAlpha{
		let l=10;
		let alpha=255/l;
		loop(l){
			ObjRender_SetAlpha(obj,alpha);
			alpha+=255/(l*2);
			yield;
			}
		}
	task TShrink{
		let l=frame;
		let a = size*2/l/l;
		ascent(i in 0..l){
			ObjRender_SetScaleXYZ(obj,size,size,0);
			size = size-i*a;
			yield;
			}
		Obj_Delete(obj);
		
	}
}

function TCharge02(x,y,size,frame,r,g,b){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/charge.png";
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,128);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,x,y,0);
	ObjRender_SetAlpha(obj,0);
	ObjRender_SetScaleXYZ(obj,size,size,0);
	ObjRender_SetColor(obj,r,g,b);
	TAlpha;
	TShrink;
	return obj;
	task TAlpha{
		let l=10;
		let alpha=255/l;
		loop(l){
			ObjRender_SetAlpha(obj,alpha);
			alpha+=255/(l*2);
			yield;
			}
		}
	task TShrink{
			let a = size/frame;
			loop(frame){
			ObjRender_SetScaleXYZ(obj,size,size,0);
			size = size-a;
			yield;
			}
		Obj_Delete(obj);
		
	}
}

task maple{
	ascent(i in 0..20){
	etama(150+i*10,i);
	etama(150+i*10,i);
	yield;
	}
	}

task etama(r,a){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/eff.png";
	r = round(r);
	let angle = [0,0,0];
	let dir = rand(0,359);
	let c = [0,0,rand(0,359)];
	let v = [-7.5,-5,-2.5,2.5,5,7.5];
	let size = r/120+1;
	let m = -10;
	let vr = rand(0,5.4);
	vr = round(vr);
	angle[2] = v[vr];
	let s = r;
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,32,226,64,254);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,size,size,0);
	ObjRender_SetAngleXYZ(obj,0,0,c[2]);
	ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	while(r>0){
	if(r>0){ObjRender_SetPosition(obj,GetEnemyX+r*cos(dir),GetEnemyY+r*sin(dir),0);}
	ObjRender_SetAngleXYZ(obj,c[0],c[1],c[2]);
	ObjRender_SetScaleXYZ(obj,size,size,0);
	ObjRender_SetColor(obj,200-r,200-r,200-r);
	size -= 3/s*7;
	r -= (12-a/5)-m/10;
	m++;
	ascent(i in 0..3){c[i] = c[i] + angle[i];}
	yield;
	}
	Obj_Delete(obj);
}

task wingset(type){
	if(type==1){
	PlaySound("BulletWave",100,0);
	wing(120,15,20,0);
	wing(-120,15,160,1);
	}
	if(type==2){
	PlaySound("BulletWave",100,0);
	wing(120,15,20,0);
	wing(-120,15,160,1);
	wait(45);
	PlaySound("BulletWave",100,0);
	wing(30,-70,-40,3);
	wing(-30,-70,220,4);
	}
	}

task wing(x,y,dir,color){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/wing.png";
	let m = 0;
	let s = 0;
	let way = 0;
	let c = 0;
	let px = 0;
	let co = [0,0,0];
	let value = 96;
	if(color==0){co = [160,0,160];}
	if(color==1){co = [160,160,0];}
	if(color==2){co = [255,160,0];}
	if(color==3){co = [0,255,160];}
	if(color==4){co = [0,160,255];}
	if(color>=2){way = 0;}
	ObjPrim_SetTexture(obj,img);
	ObjPrim_SetPrimitiveType(obj,PRIMITIVE_TRIANGLESTRIP);
	ObjSprite2D_SetSourceRect(obj,0,0,256,256);
	ObjSprite2D_SetDestCenter(obj);
	ObjPrim_SetVertexCount(obj,5);
	ObjPrim_SetVertexPosition(obj,0,-128,-128,0);
	ObjPrim_SetVertexPosition(obj,1,-128,128,0);
	ObjPrim_SetVertexPosition(obj,2,64,-128,0);
	ObjPrim_SetVertexPosition(obj,3,64,128,0);
	ObjPrim_SetVertexUVT(obj,0,0,0);
	ObjPrim_SetVertexUVT(obj,1,0,256);
	ObjPrim_SetVertexUVT(obj,2,256,0);
	ObjPrim_SetVertexUVT(obj,3,256,256);
	ObjRender_SetScaleXYZ(obj,0,0,0);
	ObjRender_SetAngleXYZ(obj,0,0,dir);
	ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	ObjRender_SetColor(obj,co[0],co[1],co[2]);
	while(!Obj_IsDeleted(objBoss)){
	if(s<1){
	if(x>0){px += 12/9;}
	if(x<0){px -= 12/9;}
	s = sin(c);
	c++;
	}
	ObjRender_SetScaleXYZ(obj,s*1.1,s*1.1,0);
	ObjRender_SetPosition(obj,GetEnemyX+px,GetEnemyY+y,0);
	ObjRender_SetAngleXYZ(obj,0,0,dir);
	if(s>=1){
	ObjPrim_SetVertexPosition(obj,2,64+48*sin(m+way),-128,0);
	ObjPrim_SetVertexPosition(obj,3,64+48*sin(m+way),128,0);
	ObjRender_SetColor(obj,co[0]+(value)*sin(m+way),co[1]+(value)*sin(m+way),co[2]+(value)*sin(m+way));
	m+=2;
	}
	yield;
	}
	Obj_Delete(obj);
}

	task Aura{
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/Aura.png";
	let color = [96,0,32];
	let value = 96;
	let dir = rand(0,359);
	let c = 0;
	let s = 2;
	ObjPrim_SetTexture(obj,img);
	ObjPrim_SetPrimitiveType(obj,PRIMITIVE_TRIANGLESTRIP);
	ObjSprite2D_SetSourceRect(obj,48,0,96,64);
	ObjSprite2D_SetDestCenter(obj);
	ObjPrim_SetVertexCount(obj,4);
	ObjPrim_SetVertexPosition(obj,0,-24,-32,0);
	ObjPrim_SetVertexPosition(obj,1,-24,32,0);
	ObjPrim_SetVertexPosition(obj,2,24,-32 ,0);
	ObjPrim_SetVertexPosition(obj,3,24, 32,0);
	ObjPrim_SetVertexUVT(obj,0,0,0);
	ObjPrim_SetVertexUVT(obj,1,0,64);
	ObjPrim_SetVertexUVT(obj,2,48,0);
	ObjPrim_SetVertexUVT(obj,3,48,64);
	ObjRender_SetAngleXYZ(obj,0,0,dir);
	ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	ObjRender_SetColor(obj,color[0],color[1],color[2]);
	Obj_SetRenderPriority(obj,0.21);
	while(s>0 && !Obj_IsDeleted(objBoss)){
	ObjRender_SetPosition(obj,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss)-10,0);
	ObjRender_SetScaleXYZ(obj,s,s,s);
	s -= 0.03;
	ObjRender_SetColor(obj,color[0]-c,color[1],color[2]+c);
	if(c==7){Aura;}
	c++;
	yield;
	}
	Obj_Delete(obj);
	}
	
task effbreak(shot,type){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GCSD~"img/effbreak.png";
	let s = rand(0.8,1.2);
	let color = [0,0,0];
	if(type=="RED"){color = [192,0,0];}
	if(type=="GREEN"){color = [0,192,0];}
	if(type=="BLUE"){color = [0,0,192];}
	if(type=="ORANGE"){color = [192,192,0];}
	if(type=="PURPLE"){color = [192,0,192];}
	if(type=="AQUA"){color = [0,192,192];}
	if(type=="GRAY"){color = [192,192,192];}
	let rect = [0,0,32,32];
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,rect[0],rect[1],rect[2],rect[3]);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,s,s,0);
	ObjRender_SetAngleXYZ(obj,0,0,rand(0,359));
	ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	ObjRender_SetColor(obj,color[0],color[1],color[2]);
	Obj_SetRenderPriority(obj,0.21);
	let x = ObjMove_GetX(shot);
	let y = ObjMove_GetY(shot);
	ascent(i in 0..7){
	ObjRender_SetPosition(obj,x,y,0);
	ObjSprite2D_SetSourceRect(obj,rect[0],rect[1],rect[2],rect[3]);
	rect[0] = rect[0]+32;
	rect[2] = rect[2]+32;
	wait(4);
	}
	Obj_Delete(obj);
	}
	

task TWaveCircle() // from sample script
{
	//レンダリングターゲットに使用するテクスチャ
	let renderTexture = GetReservedRenderTargetName(0);

	let frame = 0; //フレーム
	let baseEffectRadius = 144; //基準エフェクト半径
	let outerFluct = 16; //エフェクト半径の最大変化量
	let effectRadius = 0; //エフェクト半径
	let circleVertexCount = 16; //円をあらわすのに使用する頂点の数
	let innerCircleCount = 4;

	let priEffectMin = 20; //エフェクトをかける最小優先度
	let priEffectMax = 28; //エフェクトをかける最大優先度

	//背景のみエフェクトの対象とする
	//エフェクトの描画でまかなえるため、
	//優先度20〜28の通常描画を無効にする。
	SetInvalidRenderPriorityA1(priEffectMin, priEffectMax);


	let frameWidth = GetStgFrameWidth();
	let frameHeight = GetStgFrameHeight();
	let frameLeft = GetStgFrameLeft();
	let frameRight = frameLeft + frameWidth;
	let frameTop = GetStgFrameTop();
	let frameBottom = frameTop + frameHeight;

	//--------------------------------
	//円形の影
	let path = GetCurrentScriptDirectory() ~ "Effect02.png";
	let objShadow = ObjPrim_Create(OBJ_SPRITE_2D); //2Dスプライトオブジェクト生成
	Obj_SetRenderPriorityI(objShadow, 25); //描画優先度を設定
	ObjPrim_SetTexture(objShadow, path); //テクスチャを設定
	ObjRender_SetBlendType(objShadow, BLEND_MULTIPLY);
	ObjSprite2D_SetSourceRect(objShadow, 1, 1, 255, 255); //描画元設定(44, 54)-(71,105)
	ObjSprite2D_SetDestCenter(objShadow);
	ObjRender_SetScaleXYZ(objShadow, 1.2, 1.2, 0);


	//--------------------------------
	//円内
	let objInnerC = ObjPrim_Create(OBJ_PRIMITIVE_2D);
	Obj_SetRenderPriorityI(objInnerC, priEffectMax + 1);
	ObjPrim_SetTexture(objInnerC, renderTexture);
	ObjPrim_SetVertexCount(objInnerC, 6 * circleVertexCount * innerCircleCount);

	//円外〜エフェクト枠
	let objOuterC = ObjPrim_Create(OBJ_PRIMITIVE_2D);
	Obj_SetRenderPriorityI(objOuterC, priEffectMax + 1);
	ObjPrim_SetTexture(objOuterC, renderTexture); //テクスチャを設定
	ObjPrim_SetVertexCount(objOuterC, 3 * circleVertexCount);

	//エフェクト枠外オブジェクト
	let objOuterE = ObjPrim_Create(OBJ_SPRITE_LIST_2D);
	Obj_SetRenderPriorityI(objOuterE, priEffectMax + 1);
	ObjPrim_SetTexture(objOuterE, renderTexture); //テクスチャを設定


	//ボスのライフが0になるまでエフェクトをかける。
	let objEnemy = GetEnemyBossObjectID[0];
	while(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > 0)
	{
		//エフェクト半径
		effectRadius = baseEffectRadius + outerFluct * sin(frame*4);

		let enemyX = ObjMove_GetX(objEnemy); //敵座標X
		let enemyY = ObjMove_GetY(objEnemy); //敵座標Y
		let circleLeft = enemyX - effectRadius + frameLeft; //エフェクト円の左端
		let circleRight = enemyX + effectRadius + frameLeft; //エフェクト円の右端
		let circleTop = enemyY - effectRadius + frameTop; //エフェクト円の上端
		let circleBottom = enemyY + effectRadius + frameTop; //エフェクト円の下端

		//--------------------------------
		//優先度20〜28(背景)をエフェクト用のテクスチャに描画
		RenderToTextureA1(renderTexture, priEffectMin, priEffectMax, true);

		//--------------------------------
		//影
		ObjRender_SetPosition(objShadow, enemyX, enemyY, 0);

		//--------------------------------
		//円内
		//エフェクト内円を描画
		//ゆらいでいる部分
		ObjRender_SetPosition(objInnerC, -frameLeft, -frameTop, 0);
		ascent(let iPosI in 0 .. circleVertexCount) 
		{
			let xyOldRadius = 0;
			ascent(let iCircle in 0 .. innerCircleCount) 
			{
				let vertexIndex = (iPosI * innerCircleCount + iCircle) * 6;
				let angle1 =  iPosI * (360 / circleVertexCount);
				let angle2 =  (iPosI + 1) * (360 / circleVertexCount);

				//テクスチャのUV座標
				let uvRadius1 = iCircle * effectRadius / innerCircleCount;
				let uvRadius2 = (iCircle + 1) * effectRadius / innerCircleCount;

				//テクスチャのUV座標と描画先のXY座標を変化させることでゆらぎを表現する
				let xyRadius1t = iCircle * effectRadius / innerCircleCount;
				let xyRadius2t = (iCircle + 1) * effectRadius / innerCircleCount;
				let xyRadius1 = xyOldRadius;
				let xyBias = (xyRadius2t - xyRadius1t) / 2 + (xyRadius2t - xyRadius1t) * sin(frame*16 + (iCircle * 360 / innerCircleCount)) / 4;
				let xyRadius2 = xyRadius2t + xyBias / ((innerCircleCount - iCircle + 1) / 2);

				xyOldRadius = xyRadius2;
				if(iCircle == innerCircleCount - 1)
				{
					xyRadius2 = uvRadius2;
				}

				//上記の頂点座標を設定
				let leftBias = enemyX + frameLeft;
				let topBias = enemyY + frameTop;
				ObjPrim_SetVertexPosition(objInnerC, vertexIndex  , leftBias + xyRadius1 * cos(angle1), topBias + xyRadius1 * sin(angle1), 0);
				ObjPrim_SetVertexPosition(objInnerC, vertexIndex+1, leftBias + xyRadius2 * cos(angle1), topBias + xyRadius2 * sin(angle1), 0);
				ObjPrim_SetVertexPosition(objInnerC, vertexIndex+2, leftBias + xyRadius1 * cos(angle2), topBias + xyRadius1 * sin(angle2), 0);
			
				ObjPrim_SetVertexPosition(objInnerC, vertexIndex+3, leftBias + xyRadius1 * cos(angle2), topBias + xyRadius1 * sin(angle2), 0);
				ObjPrim_SetVertexPosition(objInnerC, vertexIndex+4, leftBias + xyRadius2 * cos(angle1), topBias + xyRadius2 * sin(angle1), 0);
				ObjPrim_SetVertexPosition(objInnerC, vertexIndex+5, leftBias + xyRadius2 * cos(angle2), topBias + xyRadius2 * sin(angle2), 0);

				ObjPrim_SetVertexUVT(objInnerC, vertexIndex  , leftBias + uvRadius1 * cos(angle1), topBias + uvRadius1 * sin(angle1));
				ObjPrim_SetVertexUVT(objInnerC, vertexIndex+1, leftBias + uvRadius2 * cos(angle1), topBias + uvRadius2 * sin(angle1));
				ObjPrim_SetVertexUVT(objInnerC, vertexIndex+2, leftBias + uvRadius1 * cos(angle2), topBias + uvRadius1 * sin(angle2));
			
				ObjPrim_SetVertexUVT(objInnerC, vertexIndex+3, leftBias + uvRadius1 * cos(angle2), topBias + uvRadius1 * sin(angle2));
				ObjPrim_SetVertexUVT(objInnerC, vertexIndex+4, leftBias + uvRadius2 * cos(angle1), topBias + uvRadius2 * sin(angle1));
				ObjPrim_SetVertexUVT(objInnerC, vertexIndex+5, leftBias + uvRadius2 * cos(angle2), topBias + uvRadius2 * sin(angle2));

			}
		}


		//--------------------------------
		//円外〜エフェクト枠
		//揺らいでいる円の外側から矩形までを埋める
		ObjRender_SetPosition(objOuterC, -frameLeft, -frameTop, 0);
		ascent(let iPosO in 0 .. circleVertexCount) 
		{
			let angle1 = iPosO * (360 / circleVertexCount);
			let angle2 = (iPosO + 1) * (360 / circleVertexCount);
			let rectX = 0;
			let rectY = 0;
			if(angle1 >= 0 && angle1 < 90)
			{
				rectX = circleRight;
				rectY = circleBottom;
			}
			else if(angle1 >= 90 && angle1 < 180)
			{
				rectX = circleLeft;
				rectY = circleBottom;
			}
			else if(angle1 >= 180 && angle1 < 270)
			{
				rectX = circleLeft;
				rectY = circleTop;
			}
			else if(angle1 >= 270 && angle1 < 360)
			{
				rectX = circleRight;
				rectY = circleTop;
			}
			let vertexIndex = iPosO * 3;
			ObjPrim_SetVertexPosition(objOuterC, vertexIndex, enemyX + effectRadius * cos(angle1) + frameLeft, enemyY + effectRadius * sin(angle1) + frameTop, 0);
			ObjPrim_SetVertexPosition(objOuterC, vertexIndex+1, rectX, rectY, 0);
			ObjPrim_SetVertexPosition(objOuterC, vertexIndex+2, enemyX + effectRadius * cos(angle2) + frameLeft, enemyY + effectRadius * sin(angle2) + frameTop, 0);

			ObjPrim_SetVertexUVT(objOuterC, vertexIndex, enemyX + effectRadius * cos(angle1) + frameLeft, enemyY + effectRadius * sin(angle1) + frameTop);
			ObjPrim_SetVertexUVT(objOuterC, vertexIndex+1, rectX, rectY);
			ObjPrim_SetVertexUVT(objOuterC, vertexIndex+2, enemyX + effectRadius * cos(angle2) + frameLeft, enemyY + effectRadius * sin(angle2) + frameTop);
			
		}
		

		//--------------------------------
		//エフェクト枠外
		//エフェクト枠外の背景を描画する
		ObjSpriteList2D_ClearVertexCount(objOuterE);
		ObjRender_SetPosition(objOuterE, -frameLeft, -frameTop, 0);
		ObjSpriteList2D_SetSourceRect(objOuterE, frameLeft, frameTop, frameRight, circleTop + 1);
		ObjSpriteList2D_SetDestRect(objOuterE, frameLeft, frameTop, frameRight, circleTop + 1);
		ObjSpriteList2D_AddVertex(objOuterE);

		ObjSpriteList2D_SetSourceRect(objOuterE, frameLeft, circleTop, circleLeft + 1, circleBottom);
		ObjSpriteList2D_SetDestRect(objOuterE, frameLeft, circleTop, circleLeft + 1, circleBottom);
		ObjSpriteList2D_AddVertex(objOuterE);

		ObjSpriteList2D_SetSourceRect(objOuterE, circleRight, circleTop, frameRight, circleBottom);
		ObjSpriteList2D_SetDestRect(objOuterE, circleRight, circleTop, frameRight, circleBottom);
		ObjSpriteList2D_AddVertex(objOuterE);

		ObjSpriteList2D_SetSourceRect(objOuterE, frameLeft, circleBottom, frameRight, frameBottom);
		ObjSpriteList2D_SetDestRect(objOuterE, frameLeft, circleBottom, frameRight, frameBottom);
		ObjSpriteList2D_AddVertex(objOuterE);

		frame++;
		yield;
	}

	//エフェクト用オブジェクト削除
	Obj_Delete(objInnerC);
	Obj_Delete(objOuterC);
	Obj_Delete(objOuterE);
	Obj_Delete(objShadow);
	ClearInvalidRenderPriority();
}