Exemplo n.º 1
0
void Player::onTouchMoved(Touch *touch, Event *event)
{
    Vec2 prev = event->getCurrentTarget()->getPosition();
    Vec2 delta =touch->getDelta();
    
    setTargetAngle(targetAngle+delta.x*rollSpeed*(rollReturnThreshold-fabsf(targetAngle)/maxRoll));
    
    Vec2 shiftPosition = delta+prev;
  
    setPosition(shiftPosition.getClampPoint(Vec2(PLAYER_LIMIT_LEFT,PLAYER_LIMIT_BOT),Vec2(PLAYER_LIMIT_RIGHT,PLAYER_LIMIT_TOP)));
}
Exemplo n.º 2
0
void Player::onAxisRepeat()
{
    Vec2 prev = this->getPosition();
    Vec2 delta =Vec2(15*axisX,-15*axisY);
    
    setTargetAngle(targetAngle+delta.x*rollSpeed*(rollReturnThreshold-fabsf(targetAngle)/maxRoll));
    
    Vec2 shiftPosition = delta+prev;
    
    setPosition(shiftPosition.getClampPoint(Vec2(PLAYER_LIMIT_LEFT,PLAYER_LIMIT_BOT),Vec2(PLAYER_LIMIT_RIGHT,PLAYER_LIMIT_TOP)));
}
Exemplo n.º 3
0
void Player::onTouchMoved(Touch *touch, Event *event)
{
    Vec2 prev = event->getCurrentTarget()->getPosition();
    Vec2 delta =touch->getDelta();
    
    setTargetAngle(targetAngle+delta.x*rollSpeed*(rollReturnThreshold-fabsf(targetAngle)/maxRoll));
    
    Vec2 shiftPosition = delta+prev;
	
	auto camera = CameraExt::getInstance();
	setPosition(shiftPosition.getClampPoint(camera->GetCameraOriginToGL(), Vec2(camera->GetCameraOriginToGL().x + camera->getCameraSize().width, camera->getMapSize().height)));
}
Exemplo n.º 4
0
void Player::onAxisRepeat()
{
    Vec2 prev = this->getPosition();
    Vec2 delta =Vec2(15*axisX,-15*axisY);
    
    setTargetAngle(targetAngle+delta.x*rollSpeed*(rollReturnThreshold-fabsf(targetAngle)/maxRoll));
    
    Vec2 shiftPosition = delta+prev;
    
	auto camera = CameraExt::getInstance();
	setPosition(shiftPosition.getClampPoint(camera->GetCameraOriginToGL(), camera->GetCameraOriginToGL()+Vec2(camera->getCameraSize().width, camera->getMapSize().height)));
}
Exemplo n.º 5
0
Asserv& Asserv::angle(int a) {
	setTargetAngle(targetAngle+a);
	return *this;
}