File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,8 @@ void Box2DDistanceJointItem::initialize()
54
54
55
55
jointDef.Initialize (m_entityA->body (),
56
56
m_entityB->body (),
57
- m_entityA->body ()->GetWorldCenter (),
58
- m_entityB->body ()->GetWorldCenter ());
57
+ m_anchorA. isNull () ? m_entityA->body ()->GetWorldCenter () : b2Util::b2Vec (m_anchorA, m_scaleRatio ),
58
+ m_anchorB. isNull () ? m_entityB->body ()->GetWorldCenter () : b2Util::b2Vec (m_anchorB, m_scaleRatio ));
59
59
60
60
61
61
m_joint = static_cast <b2DistanceJoint *>(m_worldPtr->CreateJoint (&jointDef));
Original file line number Diff line number Diff line change @@ -71,3 +71,23 @@ void Box2DJointItem::setCollideConnected(const bool &collideConnected)
71
71
emit collideConnectedChanged ();
72
72
}
73
73
}
74
+
75
+ void Box2DJointItem::setAnchorA (const QPointF &anchorA)
76
+ {
77
+ if (m_anchorA == anchorA)
78
+ return ;
79
+
80
+ m_anchorA = anchorA;
81
+
82
+ emit anchorAChanged ();
83
+ }
84
+
85
+ void Box2DJointItem::setAnchorB (const QPointF &anchorB)
86
+ {
87
+ if (m_anchorB == anchorB)
88
+ return ;
89
+
90
+ m_anchorB = anchorB;
91
+
92
+ emit anchorBChanged ();
93
+ }
Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ class Box2DJointItem : public Box2DBaseItem
35
35
Q_PROPERTY (Entity *entityA READ entityA WRITE setEntityA NOTIFY entityAChanged)
36
36
Q_PROPERTY (Entity *entityB READ entityB WRITE setEntityB NOTIFY entityBChanged)
37
37
Q_PROPERTY (bool collideConnected READ collideConnected WRITE setCollideConnected NOTIFY collideConnectedChanged)
38
+ Q_PROPERTY (QPointF anchorA READ anchorA WRITE setAnchorA NOTIFY anchorAChanged)
39
+ Q_PROPERTY (QPointF anchorB READ anchorB WRITE setAnchorB NOTIFY anchorBChanged)
38
40
39
41
public:
40
42
Box2DJointItem (Scene *parent = 0 );
@@ -49,16 +51,26 @@ class Box2DJointItem : public Box2DBaseItem
49
51
bool collideConnected () const ;
50
52
void setCollideConnected (const bool &collideConnected);
51
53
54
+ QPointF anchorA () const { return m_anchorA; }
55
+ void setAnchorA (const QPointF &anchorA);
56
+
57
+ QPointF anchorB () const { return m_anchorB; }
58
+ void setAnchorB (const QPointF &anchorB);
59
+
52
60
signals:
53
61
void entityAChanged ();
54
62
void entityBChanged ();
55
63
void collideConnectedChanged ();
64
+ void anchorAChanged ();
65
+ void anchorBChanged ();
56
66
57
67
protected:
58
68
Entity *m_entityA;
59
69
Entity *m_entityB;
60
70
bool m_collideConnected;
61
71
b2Joint *m_joint;
72
+ QPointF m_anchorA;
73
+ QPointF m_anchorB;
62
74
};
63
75
64
76
#endif /* _BOX2DJOINTITEM_H_ */
You can’t perform that action at this time.
0 commit comments