kgoldrunner
kgrsprite.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "kgrsprite.h"
00018
00019 KGrSprite::KGrSprite( KGameCanvasAbstract* canvas )
00020 : KGameCanvasPixmap(canvas)
00021 {
00022 m_frame = 0;
00023 m_loc.setX (-1);
00024 }
00025
00026 KGrSprite::~KGrSprite()
00027 {
00028 }
00029
00030 void KGrSprite::addFrames (QList<QPixmap> * frames, const QPoint & topLeft,
00031 const double scale)
00032 {
00033 m_frames = frames;
00034 m_scale = scale;
00035 m_tlX = topLeft.x();
00036 m_tlY = topLeft.y();
00037 }
00038
00039 void KGrSprite::move(double x, double y, int frame)
00040 {
00041 if (m_frame!=frame) {
00042 m_frame = frame;
00043 setPixmap(m_frames->at(m_frame));
00044 }
00045 if ((m_loc.x() != x) || (m_loc.y() != y)) {
00046 m_loc.setX ((int)x);
00047 m_loc.setY ((int)y);
00048 moveTo ((int)(x * m_scale) + m_tlX, (int)(y * m_scale) + m_tlY);
00049 }
00050 }
00051
00052 void KGrSprite::setZ (qreal )
00053 {
00054
00055 raise();
00056 }