VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
ContactTrigger.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 CONTACTTRIGGER_H
18 #define CONTACTTRIGGER_H
19 
20 #include "Actor.h"
21 #include "logics/Trigger.h"
22 #include "logics/events/ContactEvent.h"
23 
30 class ContactTrigger : public Trigger {
31  Q_OBJECT
32 public:
43 
44 
47  Actor::ActorType getActorType() { return mActorType; }
52  void setActorType(Actor::ActorType value);
56  ContactEvent::Contact getContact() { return mContact; }
62 
66  virtual void init() override;
67 
68 signals:
72  void actorTypeChanged();
76  void contactChanged();
77 
78 private:
79  bool actorTypeMatches(Body* body);
80 
81  Actor::ActorType mActorType;
82  ContactEvent::Contact mContact;
83 };
84 Q_DECLARE_METATYPE(ContactTrigger*)
85 
86 #endif // CONTACTTRIGGER_H
void contactChanged()
Emitted when contact changes.
ContactEvent::Contact contact
Contact type of this trigger.
Definition: ContactTrigger.h:37
A QObject container for a Box2D b2Body.
Definition: Body.h:57
void setActorType(Actor::ActorType value)
Sets actorType.
ActorType
Different categories of Actors, used to differentiate among them.
Definition: Actor.h:49
void setContact(ContactEvent::Contact value)
Sets contact.
Actor::ActorType actorType
Actor::ActorType that will activate this trigger.
Definition: ContactTrigger.h:42
virtual void init() override
Initializes the ContactTrigger.
Representation of an entity within the Game scene.
Definition: Actor.h:40
void actorTypeChanged()
Emitted when actorType changes.
Actor::ActorType getActorType()
Returns actorType.
Definition: ContactTrigger.h:47
Contact
Types of ContactEvents that can occur.
Definition: ContactEvent.h:37
Listens for one or more events (TriggerEvent) and calls an event handler (handleEvent()) in response ...
Definition: Trigger.h:33
ContactEvent::Contact getContact()
Returns contact.
Definition: ContactTrigger.h:56
Listens to ContactEvents between the parent Actor's Body and another body of the specified ActorType...
Definition: ContactTrigger.h:30