[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/games/granatier/src
From: Mathias Kraus <k.hias () gmx ! de>
Date: 2009-09-27 9:06:19
Message-ID: 1254042379.362373.27143.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1028440 by mkraus:
check if the element ID exists in the player SVG before setting it
M +21 -12 playeritem.cpp
M +0 -5 playeritem.h
--- trunk/playground/games/granatier/src/playeritem.cpp #1028439:1028440
@@ -40,7 +40,7 @@
// load the SVG
QString strPlayerId = ((Player*) p_model)->getGraphicsPath();
m_renderer->load(KStandardDirs::locate("appdata", \
QString("players/%1").arg(strPlayerId)));
- // A timeLine for the Player animation
+ // A timeLine for the Player animation
m_animationTimer = new QTimeLine();
m_animationTimer->setCurveShape(QTimeLine::LinearCurve);
m_animationTimer->setLoopCount(0);
@@ -49,7 +49,10 @@
m_animationTimer->setDuration(PlayerItem::ANIM_SPEED);
connect(m_animationTimer, SIGNAL(frameChanged(int)), this, SLOT(setFrame(int)));
- setElementId("player_0");
+ if(m_renderer->elementExists("player_0"))
+ {
+ setElementId("player_0");
+ }
}
PlayerItem::~PlayerItem()
@@ -57,12 +60,6 @@
delete m_animationTimer;
}
-void PlayerItem::setPlayerId(QString strPlayerId)
-{
- m_strPlayerId = strPlayerId;
- setElementId("player_0");
-}
-
void PlayerItem::updateDirection()
{
QTransform transform;
@@ -110,7 +107,10 @@
if (collidingList[i]->zValue() >= 300 && collidingList[i]->zValue() < \
400) {
//((ElementItem*)collidingList[i])->getModel()->doActionOnCollision((Player*)getModel());
- setElementId("player_death");
+ if(m_renderer->elementExists("player_death"))
+ {
+ setElementId("player_death");
+ }
dynamic_cast <Player*> (m_model)->die();
}
else if (collidingList[i]->zValue() == 100)
@@ -165,7 +165,10 @@
void PlayerItem::stopAnim()
{
- setElementId("player_0");
+ if(m_renderer->elementExists("player_0"))
+ {
+ setElementId("player_0");
+ }
if (m_animationTimer->state() == QTimeLine::Running)
{
m_animationTimer->stop();
@@ -174,11 +177,17 @@
void PlayerItem::setFrame(const int p_frame)
{
- setElementId(QString("player_%1").arg(p_frame));
+ if(m_renderer->elementExists(QString("player_%1").arg(p_frame)))
+ {
+ setElementId(QString("player_%1").arg(p_frame));
+ }
}
void PlayerItem::setDead()
{
stopAnim();
- setElementId("player_death");
+ if(m_renderer->elementExists("player_death"))
+ {
+ setElementId("player_death");
+ }
}
--- trunk/playground/games/granatier/src/playeritem.h #1028439:1028440
@@ -57,11 +57,6 @@
* Deletes the PlayerItem instance.
*/
~PlayerItem();
-
- /**
- * Player ID to get the element ID from the SVG
- */
- void setPlayerId(QString strPlayerId);
public slots:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic