VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
ContactEvent.h
1 /*
2  * Copyright (C) 2014 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CONTACTEVENT_H
18 #define CONTACTEVENT_H
19 
20 #include "logics/Trigger.h"
21 
22 class Body;
23 
29 class ContactEvent : public TriggerEvent {
30  Q_OBJECT
31 public:
32  Q_ENUMS(Contact)
33 
34 
37  enum Contact {
46  };
47 
58 
62  Q_PROPERTY(Body* otherBody READ getOtherBody() WRITE setOtherBody NOTIFY otherBodyChanged)
66  Q_PROPERTY(Contact contact READ getContact() WRITE setContact NOTIFY contactChanged)
67 
71  Body* getOtherBody() const { return mOtherBody; }
76  void setOtherBody(Body* value);
80  Contact getContact() const { return mContact; }
85  void setContact(Contact value);
86 
90  virtual QVariant toVariant() override { return QVariant::fromValue(this); }
91 
92 signals:
96  void otherBodyChanged();
100  void contactChanged();
101 
102 private:
103  Body* mOtherBody = nullptr;
104  Contact mContact;
105 };
106 Q_DECLARE_METATYPE(ContactEvent*)
107 
108 #endif // CONTACTEVENT_H
Contact contact
Contact that the event is about.
Definition: ContactEvent.h:66
A QObject container for a Box2D b2Body.
Definition: Body.h:57
void setOtherBody(Body *value)
Sets otherBody.
virtual QVariant toVariant() override
Returns the ContactEvent as a QVariant.
Definition: ContactEvent.h:90
ContactEvent()
Constructor of the ContactEvent.
Definition: ContactEvent.h:51
void setContact(Contact value)
Sets contact.
Abstract base class for events which can be handled by Triggers.
Definition: Trigger.h:68
void contactChanged()
Emitted when contact changes.
Occurs when two Bodys are no longer in contact.
Definition: ContactEvent.h:45
QVariant fromValue(const T &value)
Raised when two Bodys begin or end contact with each other.
Definition: ContactEvent.h:29
Contact getContact() const
Returns contact.
Definition: ContactEvent.h:80
void otherBodyChanged()
Emitted when otherBody changes.
Occurs when two Bodys come in contact.
Definition: ContactEvent.h:41
WRITE setContact NOTIFY contactChanged Body * getOtherBody() const
Returns otherBody.
Definition: ContactEvent.h:71
Body otherBody
Body that is in contact with the Body that is receieving this ContactEvent.
Definition: ContactEvent.h:62
Contact
Types of ContactEvents that can occur.
Definition: ContactEvent.h:37