VoltAir
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Groups
Pages
Engine
logics
events
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
{
41
ContactBegun
= 0,
45
ContactEnded
46
};
47
51
ContactEvent
() { }
57
ContactEvent
(
Body
* body,
Contact
contact
);
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
ContactEvent::contact
Contact contact
Contact that the event is about.
Definition:
ContactEvent.h:66
Body
A QObject container for a Box2D b2Body.
Definition:
Body.h:57
ContactEvent::setOtherBody
void setOtherBody(Body *value)
Sets otherBody.
ContactEvent::toVariant
virtual QVariant toVariant() override
Returns the ContactEvent as a QVariant.
Definition:
ContactEvent.h:90
ContactEvent::ContactEvent
ContactEvent()
Constructor of the ContactEvent.
Definition:
ContactEvent.h:51
ContactEvent::setContact
void setContact(Contact value)
Sets contact.
TriggerEvent
Abstract base class for events which can be handled by Triggers.
Definition:
Trigger.h:68
ContactEvent::contactChanged
void contactChanged()
Emitted when contact changes.
ContactEvent::ContactEnded
Occurs when two Bodys are no longer in contact.
Definition:
ContactEvent.h:45
QVariant::fromValue
QVariant fromValue(const T &value)
ContactEvent
Raised when two Bodys begin or end contact with each other.
Definition:
ContactEvent.h:29
ContactEvent::getContact
Contact getContact() const
Returns contact.
Definition:
ContactEvent.h:80
ContactEvent::otherBodyChanged
void otherBodyChanged()
Emitted when otherBody changes.
ContactEvent::ContactBegun
Occurs when two Bodys come in contact.
Definition:
ContactEvent.h:41
ContactEvent::getOtherBody
WRITE setContact NOTIFY contactChanged Body * getOtherBody() const
Returns otherBody.
Definition:
ContactEvent.h:71
ContactEvent::otherBody
Body otherBody
Body that is in contact with the Body that is receieving this ContactEvent.
Definition:
ContactEvent.h:62
ContactEvent::Contact
Contact
Types of ContactEvents that can occur.
Definition:
ContactEvent.h:37
QVariant