#include "MenuTextP1Ball.h"

MenuTextP1Ball::MenuTextP1Ball()
{
	ani.png = L"menu_CS_title";
	ani.sprite_index = L"icon_player1";
}

void MenuTextP1Ball::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 MenuTextP1Ball::SetState(int stateID, int lr)
{
	this->stateID = stateID;
}

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

std::shared_ptr<Entity> CreateMenuTextP1Ball()
{
	return std::make_shared<MenuTextP1Ball>();
}


