• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kgoldrunner

kgrsprite.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                          kgrsprite.cpp  -  description
00003                              -------------------
00004     begin                : Fri Aug 04 2006
00005     Copyright 2006 Mauricio Piacentini <mauricio@tabuleiro.com>
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
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);        // Makes move() work OK if first (x,y) is (0,0).
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 /* z (unused) */)
00053 {
00054     // Hero and enemy sprites are above other elements.
00055     raise();
00056 }

kgoldrunner

Skip menu "kgoldrunner"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

API Reference

Skip menu "API Reference"
  • kblackbox
  • kgoldrunner
  • kmahjongg
  • ksquares
  • libkdegames
  •   highscore
  •   kgame
  •   kggzgames
  •   kggzmod
  •   kggznet
  • libkmahjongg
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal