summaryrefslogtreecommitdiffstats
path: root/examples/statemachine
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-05-14 10:33:05 +0200
committerEskil Abrahamsen Blomfeldt <eblomfel@trolltech.com>2009-05-14 10:33:05 +0200
commit66d8ad206cca48d8193785bdf685f5d1fba80f02 (patch)
tree5c5e4cf555b1586c93d9ed7f87d05bdb557c0db6 /examples/statemachine
parent3cd4b6e00e3448d880ae2335bd50f70d9a5d0fca (diff)
Fix SpinState in Tank Game Example to spin more than 180 degrees
This was a leftover from when the setDirection() semantics were broken.
Diffstat (limited to 'examples/statemachine')
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai/spin_ai.h7
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h7
2 files changed, 12 insertions, 2 deletions
diff --git a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.h b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.h
index a331a3e283..d8d3d738b7 100644
--- a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.h
+++ b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.h
@@ -18,7 +18,7 @@ public:
public slots:
void spin()
{
- m_tank->setProperty("direction", 90.0);
+ m_tank->setProperty("direction", m_tank->property("direction").toDouble() + 90.0);
}
protected:
@@ -28,6 +28,11 @@ protected:
spin();
}
+ void onExit(QEvent *)
+ {
+ disconnect(m_tank, SIGNAL(actionCompleted()), this, SLOT(spin()));
+ }
+
private:
QObject *m_tank;
diff --git a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h
index 5cfb3649c8..456ba017bc 100644
--- a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h
+++ b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h
@@ -18,7 +18,7 @@ public:
public slots:
void spin()
{
- m_tank->setProperty("direction", 90.0);
+ m_tank->setProperty("direction", m_tank->property("direction").toDouble() + 90.0);
}
protected:
@@ -28,6 +28,11 @@ protected:
spin();
}
+ void onExit(QEvent *)
+ {
+ disconnect(m_tank, SIGNAL(actionCompleted()), this, SLOT(spin()));
+ }
+
private:
QObject *m_tank;