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))); }
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))); }
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))); }
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))); }
Asserv& Asserv::angle(int a) { setTargetAngle(targetAngle+a); return *this; }