/**
 * 指定したフレーム数処理を止める
 * 
 * @param {Integer} time 待つフレーム数
 */
function FWait( time ){
	loop( time ){
		yield;
	}
}

/**
 * 
 */
task CreateObjSpellEffectShot( x, y, speed, angle, rad, pow, time, roll, imgPath, cutx, cuty, sizex, sizey ){
	let obj = CreateObjSpellEffect( x, y, imgPath, cutx, cuty, sizex, sizey );
	ObjEffect_SetAngle( obj, 0, 0, angle );
	let mx = speed * cos( angle );
	let my = speed * sin( angle );
	let count = 0;
	let rotate = angle;
	
	while( !Obj_BeDeleted( obj ) ){
		x = Obj_GetX( obj );
		y = Obj_GetY( obj );
		
		x += mx;
		y += my;
		
		rotate += roll;
		
		Obj_SetPosition( obj, x, y );
		ObjEffect_SetAngle( obj, 0, 0, rotate );
		
		//当たり判定
		if( rad > 0 ){
			ObjSpell_SetIntersecrionCircle( obj, x, y, rad, pow, true );
		}
		
		count += 1;
		
		//時間削除
		if( count > time ){
			Obj_Delete( obj );
		}
		
		yield;
	}
}

/**
 * ショットオブジェクトを作成して返す
 * 
 * @param {Integer} x      x座標
 * @param {Integer} y      y座標
 * @param {String} imgPath 画像パス
 * @return オブジェクトID
 */
function CreateObjSpellEffect( x, y, imgPath, cutx, cuty, sizex, sizey ){
	let sizexhalf = sizex / 2;
	let sizeyhalf = sizey / 2;
	
	let obj = Obj_Create( OBJ_SPELL );
	ObjEffect_SetTexture( obj, imgPath );
	ObjEffect_SetPrimitiveType( obj, PRIMITIVE_TRIANGLESTRIP );
	ObjEffect_CreateVertex( obj, 4 );
	
	ObjEffect_SetVertexXY( obj, 0, -sizexhalf, -sizeyhalf );
	ObjEffect_SetVertexXY( obj, 1, -sizexhalf,  sizeyhalf );
	ObjEffect_SetVertexXY( obj, 2,  sizexhalf, -sizeyhalf );
	ObjEffect_SetVertexXY( obj, 3,  sizexhalf,  sizeyhalf );
	
	ObjEffect_SetVertexUV( obj, 0, cutx +     0, cuty +     0 );
	ObjEffect_SetVertexUV( obj, 1, cutx +     0, cuty + sizey );
	ObjEffect_SetVertexUV( obj, 2, cutx + sizex, cuty +     0 );
	ObjEffect_SetVertexUV( obj, 3, cutx + sizex, cuty + sizey );
	
	ObjEffect_SetVertexColor( obj, 0, 255, 255, 255, 255);
	ObjEffect_SetVertexColor( obj, 1, 255, 255, 255, 255);
	ObjEffect_SetVertexColor( obj, 2, 255, 255, 255, 255);
	ObjEffect_SetVertexColor( obj, 3, 255, 255, 255, 255);
	
	Obj_SetPosition( obj, x, y );
	
	return obj;
}