Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
5ad869c6
Commit
5ad869c6
authored
Nov 05, 2014
by
Gavin Bisesi
Browse files
Merge pull request #378 from poixen/animation
Card Animation performance improvement
parents
67db347d
097090ac
Changes
4
Show whitespace changes
Inline
Side-by-side
cockatrice/src/carditem.cpp
View file @
5ad869c6
...
...
@@ -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
();
...
...
cockatrice/src/carditem.h
View file @
5ad869c6
...
...
@@ -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
...
...
cockatrice/src/gamescene.cpp
View file @
5ad869c6
...
...
@@ -262,7 +262,7 @@ void GameScene::registerAnimationItem(AbstractCardItem *card)
{
cardsToAnimate
.
insert
(
static_cast
<
CardItem
*>
(
card
));
if
(
!
animationTimer
->
isActive
())
animationTimer
->
start
(
5
0
,
this
);
animationTimer
->
start
(
1
5
,
this
);
}
void
GameScene
::
unregisterAnimationItem
(
AbstractCardItem
*
card
)
...
...
cockatrice/src/phasestoolbar.cpp
View file @
5ad869c6
...
...
@@ -65,7 +65,7 @@ void PhaseButton::setActive(bool _active)
return
;
active
=
_active
;
activeAnimationTimer
->
start
(
5
0
);
activeAnimationTimer
->
start
(
2
5
);
}
void
PhaseButton
::
updateAnimation
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment