gameEngine/gameEngine/Sprite.cpp
//add circle collider to sprite, auto recenter circle before placing
add circle collider to sprite, auto recenter circle before placing
add circle collider to sprite auto recenter circle before placing
void Sprite::addCircleCollider(std::string name, float r, int posX, int posY)
{
	float r2 = r * 2;
	int diffY = 0;
	int diffX = 0;
	if (r2 != this->getSize().x || r2 != this->getSize().y)
	{
		diffX = int(r - this->getSize().x/2);
		diffY = int(r - this->getSize().y/2);
	}
	CircleCollider *temp = new CircleCollider(name, *this, r, this->Position.x + posX - diffX, this->Position.y + posY - diffY);
	this->colliders_.push_back(temp);
}
void Sprite :: addCircleCollider ( std :: string name , float r , int posX , int posY ) { float r2 = r * 2 ; int diffY = 0 ; int diffX = 0 ; if ( r2 != this -> getSize ( ) . x || r2 != this -> getSize ( ) . y ) { diffX = int ( r - this -> getSize ( ) . x / 2 ) ; diffY = int ( r - this -> getSize ( ) . y / 2 ) ; } CircleCollider * temp = new CircleCollider ( name , * this , r , this -> Position . x + posX - diffX , this -> Position . y + posY - diffY ) ; this -> colliders_ . push_back ( temp ) ; }
add circle collider to sprite, auto recenter circle before placing
add circle collider to sprite auto recenter circle before placing
//if doesn't fit to sprite, we need to recenter the circle //get x and y offset