Merge pull request #378 from poixen/animation

Card Animation performance improvement
This commit is contained in:
Gavin Bisesi 2014-11-05 15:45:24 -05:00
commit 5ad869c636
4 changed files with 13 additions and 8 deletions

View file

@ -17,6 +17,7 @@
#include "tab_game.h"
#include "pb/serverinfo_card.pb.h"
CardItem::CardItem(Player *_owner, const QString &_name, int _cardid, bool _revealedCard, QGraphicsItem *parent)
: AbstractCardItem(_name, _owner, _cardid, parent), zone(0), revealedCard(_revealedCard), attacking(false), destroyOnZoneChange(false), doesntUntap(false), dragItem(0), attachedTo(0)
{
@ -360,15 +361,16 @@ void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
event->accept();
}
bool CardItem::animationEvent()
{
int delta = 18;
int rotation = ROTATION_DEGREES_PER_FRAME;
if (!tapped)
delta *= -1;
rotation *= -1;
tapAngle += delta;
tapAngle += rotation;
setTransform(QTransform().translate((float) CARD_WIDTH / 2, (float) CARD_HEIGHT / 2).rotate(tapAngle).translate((float) -CARD_WIDTH / 2, (float) -CARD_HEIGHT / 2));
setTransform(QTransform().translate(CARD_WIDTH_HALF, CARD_HEIGHT_HALF).rotate(tapAngle).translate(-CARD_WIDTH_HALF, -CARD_HEIGHT_HALF));
setHovered(false);
update();

View file

@ -12,6 +12,9 @@ class QAction;
class QColor;
const int MAX_COUNTERS_ON_CARD = 999;
const float CARD_WIDTH_HALF = CARD_WIDTH / 2;
const float CARD_HEIGHT_HALF = CARD_HEIGHT / 2;
const int ROTATION_DEGREES_PER_FRAME = 10;
class CardItem : public AbstractCardItem {
Q_OBJECT

View file

@ -262,7 +262,7 @@ void GameScene::registerAnimationItem(AbstractCardItem *card)
{
cardsToAnimate.insert(static_cast<CardItem *>(card));
if (!animationTimer->isActive())
animationTimer->start(50, this);
animationTimer->start(15, this);
}
void GameScene::unregisterAnimationItem(AbstractCardItem *card)

View file

@ -65,7 +65,7 @@ void PhaseButton::setActive(bool _active)
return;
active = _active;
activeAnimationTimer->start(50);
activeAnimationTimer->start(25);
}
void PhaseButton::updateAnimation()