#include "MenuTextP2Ball.h"

MenuTextP2Ball::MenuTextP2Ball()
{
	ani.png = L"menu_CS_title";
	ani.sprite_index = L"icon_player2";
}

void MenuTextP2Ball::Step()
{
	if (bInitPos)
	{
		xSrc = x;
		ySrc = y;
		bInitPos = false;
	}
	//执行运动
	Entity::Step();
	switch (stateID)
	{
	case 0://复位
		x = xSrc;
		y = ySrc;
		break;
	case 1://移动到键盘
		x += (keyboardPlace_x - x) / speed;
		y += (keyboardPlace_y - y) / speed;
		break;
	case 2://移动到手柄1
		x += (joystick1Place_x - x) / speed;
		y += (joystick1Place_y - y) / speed;
		break;
	case 3://移动到手柄2
		x += (joystick2Place_x - x) / speed;
		y += (joystick2Place_y - y) / speed;
		break;
	}
}

void MenuTextP2Ball::SetState(int stateID, int lr)
{
	this->stateID = stateID;
}

void MenuTextP2Ball::Reset()
{
	x = xSrc;
	y = ySrc;
	stateID = 0;
}

std::shared_ptr<Entity> CreateMenuTextP2Ball()
{
	return std::make_shared<MenuTextP2Ball>();
}


