本文整理汇总了C++中Portal::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Portal::setPosition方法的具体用法?C++ Portal::setPosition怎么用?C++ Portal::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portal
的用法示例。
在下文中一共展示了Portal::setPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void Hero::update()
{
if (mySpawnPortal)
{
mySpawnPortalFrameCounter++;
if (mySpawnPortalFrameCounter == 1)
{
Portal* portal = new Portal();
portal->setPosition(getPosition());
getRoom()->addEntity(portal);
return;
}
else if (mySpawnPortalFrameCounter >= 60 * 5)
{
mySpawnPortal = false;
}
else
{
return;
}
}
if (myIsDead)
return;
Entity::update();
mFramesSinceLandPlayed++;
if (mGravityHitTimer <= 0){
mGravityDirection=1;
} else {
mGravityHitTimer--;
}
if (touchesDangerousTile())
{
die();
}
//checkEnemies();
if (mSpawnPoint.x < -100 && mSpawnPoint.y < -100)
{
mSpawnPoint = getPosition();
}
float acceleration = mOnGround ? GROUND_ACCELERATION : AIR_ACCELERATION;
if (Input::isHeld(Button_Left)) {
mVelocity.x -= acceleration;
mFacingDirection = Direction_Left;
}
if (Input::isHeld(Button_Right)) {
mVelocity.x += acceleration;
mFacingDirection = Direction_Right;
}
if(Input::isPressed(Button_Fire) && GameState::getInt(GameState::POWERUP_GRENADE) != 0){
mWeaponSelected = Weapon_Gravity_Grenade;
fireWeapon();
}
if(Input::isPressed(Button_ToggleWeapon) && GameState::getInt(GameState::POWERUP_GUN) != 0){
mWeaponSelected = Weapon_Gun;
fireWeapon();
}
mVelocity.x = clamp(mVelocity.x, -MAX_X_VELOCITY, MAX_X_VELOCITY);
if (Input::isPressed(Button_Jump)) {
mJumpPrepressed = true;
}
if (mOnGround && mJumpPrepressed) {
Sound::playSample("data/sounds/jump.wav");
mVelocity.y = GameState::getInt(GameState::POWERUP_HIJUMP) ? -HI_JUMP_VELOCITY : -JUMP_VELOCITY;
mJumpHeld = true;
mJumpPrepressed = false;
}
if (Input::isReleased(Button_Jump)) {
if (mJumpHeld && mVelocity.y < 0) {
mVelocity.y *= 0.5f;
}
mJumpHeld = false;
mJumpPrepressed = false;
}
if (mVelocity.y >= 0) {
mJumpHeld = false;
}
mMovementState = MovementState_Still;
if (mOnGround) {
if (abs(mVelocity.x) > GROUND_STOP_VELOCITY)
{
mMovementState = MovementState_Run;
}
//.........这里部分代码省略.........