Animations in KChess and CGT

Qt 4.6 release brought many improvements, most notably the Animation Framework. Though it works for any QObject and any property, I’ve only implemented it for graphics items and their position. The API is very simple: all I had to do was replace calls such as:

item->setPos(newPos);

to this:

QPropertyAnimation* animation = new QPropertyAnimation(item, "pos");
animation->setStartValue(item->pos());
animation->setEndValue(newPos);
animation->start(QAbstractAnimation::DeleteWhenFinished);

Now, opponent’s moves in KChess and moving or reordering cards in CGTable feels smoother and much more natural.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: