PIXI Controls: Safe area in Edit Mode
This commit is contained in:
parent
32b6bf4cd5
commit
ea9eb54955
1 changed files with 17 additions and 2 deletions
|
@ -263,6 +263,19 @@ ONSControls.updateButtons = function() {
|
|||
console.log("ONSControls: Controls updated");
|
||||
}
|
||||
//=============================================================================
|
||||
// * Check if element in safe area
|
||||
//=============================================================================
|
||||
ONSControls.isSafeArea = function(element, position) {
|
||||
if (position.x - element.width/2 <= ConfigManager.ONSConfig.safeArea ||
|
||||
position.x + element.width/2 >= this._controlsCanvas.screen.width - ConfigManager.ONSConfig.safeArea ||
|
||||
position.y - element.width/2 <= ConfigManager.ONSConfig.safeArea ||
|
||||
position.y + element.width/2 >= this._controlsCanvas.screen.height - ConfigManager.ONSConfig.safeArea) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//=============================================================================
|
||||
// * Setup controls touch events
|
||||
//=============================================================================
|
||||
ONSControls.setupInteractive = function () {
|
||||
|
@ -355,8 +368,10 @@ ONSControls.setupDragNDrop = function(element) {
|
|||
}
|
||||
var onMove = function(event) {
|
||||
if (element) {
|
||||
element.parent.toLocal(event.data.global, null, element.position);
|
||||
ConfigManager.ONSConfig.customPos = true;
|
||||
if (ONSControls.isSafeArea(element, event.data.global)) {
|
||||
element.parent.toLocal(event.data.global, null, element.position);
|
||||
ConfigManager.ONSConfig.customPos = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
var onEnd = function(event) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue