Пример #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)));
}
Пример #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)));
}
Пример #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)));
}
Пример #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)));
}
Пример #5
0
Asserv& Asserv::angle(int a) {
	setTargetAngle(targetAngle+a);
	return *this;
}