• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

libkdegames

Public Member Functions | Protected Member Functions | List of all members
KGameRendererClient Class Referenceabstract

#include <KGameRendererClient>

Inheritance diagram for KGameRendererClient:
Inheritance graph
[legend]

Public Member Functions

 KGameRendererClient (KGameRenderer *renderer, const QString &spriteKey)
 
virtual ~KGameRendererClient ()
 
QHash< QColor, QColor > customColors () const
 
int frame () const
 
int frameCount () const
 
KGameRenderer * renderer () const
 
QSize renderSize () const
 
void setCustomColors (const QHash< QColor, QColor > &customColors)
 
void setFrame (int frame)
 
void setRenderSize (const QSize &renderSize)
 
void setSpriteKey (const QString &spriteKey)
 
QString spriteKey () const
 

Protected Member Functions

virtual void receivePixmap (const QPixmap &pixmap)=0
 

Detailed Description

An object that receives pixmaps from a KGameRenderer.

Since
4.6 This class abstracts a sprite rendered by KGameRenderer. Given a sprite key, render size and possibly a frame index, it returns the QPixmap for this sprite (frame) once it becomes available. See the KGameRenderer class documentation for details.

Subclasses have to reimplement the receivePixmap() method.

Definition at line 50 of file kgamerendererclient.h.

Constructor & Destructor Documentation

KGameRendererClient::KGameRendererClient ( KGameRenderer *  renderer,
const QString &  spriteKey 
)

Creates a new client which receives pixmaps for the sprite with the given spriteKey as provided by the given renderer.

Definition at line 32 of file kgamerendererclient.cpp.

KGameRendererClient::~KGameRendererClient ( )
virtual

Definition at line 40 of file kgamerendererclient.cpp.

Member Function Documentation

QHash< QColor, QColor > KGameRendererClient::customColors ( ) const
Returns
the custom color replacements for this client

Definition at line 112 of file kgamerendererclient.cpp.

int KGameRendererClient::frame ( ) const
Returns
the current frame number, or -1 for non-animated sprites

Definition at line 70 of file kgamerendererclient.cpp.

int KGameRendererClient::frameCount ( ) const
Returns
the frame count, or 0 for non-animated sprites, or -1 if the sprite does not exist at all
See also
KGameRenderer::frameCount()

Definition at line 65 of file kgamerendererclient.cpp.

virtual void KGameRendererClient::receivePixmap ( const QPixmap &  pixmap)
protectedpure virtual

This method is called when the KGameRenderer has provided a new pixmap for this client (esp.

after theme changes and after calls to setFrame(), setRenderSize() and setSpriteKey()).

Implemented in KGameRenderedObjectItem, and KGameRenderedItem.

KGameRenderer * KGameRendererClient::renderer ( ) const
Returns
the renderer used by this client

Definition at line 46 of file kgamerendererclient.cpp.

QSize KGameRendererClient::renderSize ( ) const
Returns
the size of the pixmap requested from KGameRenderer

Definition at line 98 of file kgamerendererclient.cpp.

void KGameRendererClient::setCustomColors ( const QHash< QColor, QColor > &  customColors)

Defines the custom color replacements for this client.

That is, for each entry in this has, the key color will be replaced by its value if it is encountered in the sprite.

Note
Custom colors increase the rendering time considerably, so use this feature only if you really need its flexibility.

Definition at line 117 of file kgamerendererclient.cpp.

void KGameRendererClient::setFrame ( int  frame)

For animated sprites, render another frame.

The given frame number is normalized by taking the modulo of the frame count, so the following code works fine:

class MyClient : public KGameRendererClient { ... }
MyClient client;
client.setFrame(client.frame() + 1); //cycle to next frame
client.setFrame(KRandom::random()); //choose a random frame

Definition at line 75 of file kgamerendererclient.cpp.

void KGameRendererClient::setRenderSize ( const QSize &  renderSize)

Defines the size of the pixmap that will be requested from KGameRenderer.

For pixmaps rendered on the screen, you usually want to set this size such that the pixmap does not have to be scaled when it is rendered onto your primary view (for speed reasons).

The default render size is very small (width = height = 3 pixels), so that you notice when you forget to set this. ;-)

Definition at line 103 of file kgamerendererclient.cpp.

void KGameRendererClient::setSpriteKey ( const QString &  spriteKey)

Defines the key of the sprite which is rendered by this client.

Definition at line 56 of file kgamerendererclient.cpp.

QString KGameRendererClient::spriteKey ( ) const
Returns
the key of the sprite currently rendered by this client

Definition at line 51 of file kgamerendererclient.cpp.


The documentation for this class was generated from the following files:
  • kgamerendererclient.h
  • kgamerendererclient.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdegames

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

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal