#include <animateditem.h>
Inheritance diagram for AnimatedPixmapItem:


Definition at line 29 of file animateditem.h.
Public Member Functions | |
| AnimatedPixmapItem (const QList< QPixmap > &animation, QGraphicsScene *scene=0) | |
| void | setFrame (int frame) |
| int | frame () const |
| int | frameCount () const |
| QPixmap | image (int frame) const |
| void | setVelocity (qreal xvel, qreal yvel) |
| qreal | xVelocity () const |
| qreal | yVelocity () const |
| QPainterPath | shape () const |
| void | advance (int phase) |
Private Attributes | |
| int | currentFrame |
| QList< QPixmap > | frames |
| qreal | vx |
| qreal | vy |
| AnimatedPixmapItem::AnimatedPixmapItem | ( | const QList< QPixmap > & | animation, | |
| QGraphicsScene * | scene = 0 | |||
| ) |
Definition at line 26 of file animateditem.cpp.
00028 : QGraphicsPixmapItem(0, scene), currentFrame(0), frames(animation), vx(0), vy(0) 00029 { 00030 }
| void AnimatedPixmapItem::setFrame | ( | int | frame | ) |
Definition at line 32 of file animateditem.cpp.
References QList< T >::at(), currentFrame, frames, QList< T >::isEmpty(), QGraphicsPixmapItem::setPixmap(), and QList< T >::size().
Referenced by KAsteroidsView::newShip(), KRock::nextFrame(), KAsteroidsView::processShip(), and KAsteroidsView::rockHit().
00033 { 00034 if (!frames.isEmpty()) { 00035 currentFrame = frame % frames.size(); 00036 setPixmap(frames.at(currentFrame)); 00037 } 00038 }
Here is the call graph for this function:

| int AnimatedPixmapItem::frame | ( | ) | const [inline] |
Definition at line 35 of file animateditem.h.
References currentFrame.
Referenced by KRock::nextFrame(), and KAsteroidsView::processShip().
00036 { return currentFrame; }
| int AnimatedPixmapItem::frameCount | ( | ) | const [inline] |
Definition at line 37 of file animateditem.h.
References frames, and QList< T >::size().
Referenced by KRock::nextFrame(), KAsteroidsView::processShip(), and KAsteroidsView::rockHit().
Here is the call graph for this function:

| QPixmap AnimatedPixmapItem::image | ( | int | frame | ) | const [inline] |
Definition at line 39 of file animateditem.h.
References QList< T >::at(), frames, QList< T >::isEmpty(), and QList< T >::size().
Referenced by KAsteroidsView::readSprites().
Here is the call graph for this function:

| void AnimatedPixmapItem::setVelocity | ( | qreal | xvel, | |
| qreal | yvel | |||
| ) | [inline] |
Definition at line 41 of file animateditem.h.
Referenced by KAsteroidsView::newShip(), KAsteroidsView::processShip(), and KAsteroidsView::rockHit().
| qreal AnimatedPixmapItem::xVelocity | ( | ) | const [inline] |
Definition at line 43 of file animateditem.h.
References vx.
Referenced by KAsteroidsView::rockHit().
00044 { return vx; }
| qreal AnimatedPixmapItem::yVelocity | ( | ) | const [inline] |
Definition at line 45 of file animateditem.h.
References vy.
Referenced by KAsteroidsView::rockHit().
00046 { return vy; }
| QPainterPath AnimatedPixmapItem::shape | ( | ) | const [virtual] |
Reimplemented from QGraphicsPixmapItem.
Definition at line 50 of file animateditem.cpp.
References QList< T >::at(), currentFrame, frames, QPixmap::height(), path, and QPixmap::width().
00051 { 00052 QPainterPath path; 00053 path.addRect(0, 0, 00054 frames.at(currentFrame).width(), 00055 frames.at(currentFrame).height()); 00056 return path; 00057 }
Here is the call graph for this function:

| void AnimatedPixmapItem::advance | ( | int | phase | ) | [virtual] |
This virtual function is called twice for all items by the QGraphicsScene::advance() slot. In the first phase, all items are called with phase == 0, indicating that items on the scene are about to advance, and then all items are called with phase == 1. Reimplement this function to update your item if you need simple scene-controlled animation.
The default implementation does nothing.
For individual item animation, an alternative to this function is to either use QGraphicsItemAnimation, or to multiple-inherit from QObject and QGraphicsItem, and animate your item using QObject::startTimer() and QObject::timerEvent().
Reimplemented from QGraphicsItem.
Definition at line 40 of file animateditem.cpp.
References QList< T >::at(), currentFrame, frames, QList< T >::isEmpty(), QGraphicsItem::moveBy(), QGraphicsPixmapItem::setPixmap(), QList< T >::size(), vx, and vy.
00041 { 00042 if (phase == 1 && !frames.isEmpty()) { 00043 currentFrame = (currentFrame + 1) % frames.size(); 00044 setPixmap(frames.at(currentFrame)); 00045 if (vx || vy) 00046 moveBy(vx, vy); 00047 } 00048 }
Here is the call graph for this function:

int AnimatedPixmapItem::currentFrame [private] |
Definition at line 53 of file animateditem.h.
Referenced by advance(), frame(), setFrame(), and shape().
QList<QPixmap> AnimatedPixmapItem::frames [private] |
Definition at line 54 of file animateditem.h.
Referenced by advance(), frameCount(), image(), setFrame(), and shape().
qreal AnimatedPixmapItem::vx [private] |
Definition at line 55 of file animateditem.h.
Referenced by advance(), setVelocity(), and xVelocity().
qreal AnimatedPixmapItem::vy [private] |
Definition at line 55 of file animateditem.h.
Referenced by advance(), setVelocity(), and yVelocity().
1.5.1