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

granatier

  • sources
  • kde-4.14
  • kdegames
  • granatier
  • src
arenaitem.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2009 Mathias Kraus <k.hias@gmx.de>
3  * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
4  * Copyright 2007-2008 Pierre-BenoĆ®t Besse <besse.pb@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "arenaitem.h"
21 #include "granatierglobals.h"
22 
23 #include <QGraphicsView>
24 #include <KGameRenderer>
25 
26 ArenaItem::ArenaItem(qreal p_x, qreal p_y, KGameRenderer* renderer, const QString& spriteKey) : KGameRenderedItem(renderer, spriteKey)
27 {
28  // Init the view coordinates
29  setPos(p_x, p_y);
30 }
31 
32 ArenaItem::~ArenaItem()
33 {
34 }
35 
36 void ArenaItem::updateGraphics(qreal svgScaleFactor)
37 {
38  if(scene()->views().isEmpty())
39  {
40  return;
41  }
42 
43  QPoint topLeft = scene()->views().first()->mapFromScene(0, 0);
44  QPoint bottomRight = scene()->views().first()->mapFromScene(Granatier::CellSize, Granatier::CellSize);
45 
46  int width = bottomRight.x() - topLeft.x();
47  int height = bottomRight.y() - topLeft.y();
48 
49  setRenderSize(QSize(width, height));
50  setScale(svgScaleFactor);
51 }
arenaitem.h
QPoint
QPoint::x
int x() const
QPoint::y
int y() const
ArenaItem::~ArenaItem
~ArenaItem()
Deletes the ArenaItem instances.
Definition: arenaitem.cpp:32
Granatier::CellSize
const qreal CellSize
The Cell size.
Definition: granatierglobals.h:31
granatierglobals.h
QString
ArenaItem::ArenaItem
ArenaItem(qreal p_x, qreal p_y, KGameRenderer *renderer, const QString &spriteKey)
Creates a new ArenaItem instances.
Definition: arenaitem.cpp:26
QSize
ArenaItem::updateGraphics
virtual void updateGraphics(qreal svgScaleFactor)
Updates the graphics after a resize.
Definition: arenaitem.cpp:36
KGameRenderedItem
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

granatier

Skip menu "granatier"
  • 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