|
9 | 9 | ;(function($, window, document, undefined){
|
10 | 10 |
|
11 | 11 | var defaults = {
|
12 |
| - colliders_context: document.body |
| 12 | + colliders_context: document.body, |
| 13 | + overlapping_region: 'C' |
13 | 14 | // ,on_overlap: function(collider_data){},
|
14 | 15 | // on_overlap_start : function(collider_data){},
|
15 | 16 | // on_overlap_stop : function(collider_data){}
|
|
27 | 28 | * of HTMLElements or an Array of Coords instances.
|
28 | 29 | * @param {Object} [options] An Object with all options you want to
|
29 | 30 | * overwrite:
|
| 31 | + * @param {String} [options.overlapping_region] Determines when collision |
| 32 | + * is valid, depending on the overlapped area. Values can be: 'N', 'S', |
| 33 | + * 'W', 'E', 'C' or 'all'. Default is 'C'. |
30 | 34 | * @param {Function} [options.on_overlap_start] Executes a function the first
|
31 | 35 | * time each `collider ` is overlapped.
|
32 | 36 | * @param {Function} [options.on_overlap_stop] Executes a function when a
|
|
126 | 130 |
|
127 | 131 | fn.find_collisions = function(player_data_coords){
|
128 | 132 | var self = this;
|
| 133 | + var overlapping_region = this.options.overlapping_region; |
129 | 134 | var colliders_coords = [];
|
130 | 135 | var colliders_data = [];
|
131 | 136 | var $colliders = (this.colliders || this.$colliders);
|
|
149 | 154 | player_coords, collider_coords);
|
150 | 155 |
|
151 | 156 | //todo: make this an option
|
152 |
| - if (region === 'C'){ |
| 157 | + if (region === overlapping_region || overlapping_region === 'all') { |
| 158 | + |
153 | 159 | var area_coords = self.calculate_overlapped_area_coords(
|
154 | 160 | player_coords, collider_coords);
|
155 | 161 | var area = self.calculate_overlapped_area(area_coords);
|
|
0 commit comments