content/hifi-content/elisalj/zombies/scripts/button1.js
2022-02-13 23:16:46 +01:00

81 lines
No EOL
1.7 KiB
JavaScript

//
// button1.js
// A script for the first button in the zombie game
//
// Author: Elisa Lupin-Jimenez
// Copyright High Fidelity 2018
//
// Licensed under the Apache 2.0 License
// See accompanying license file or http://apache.org/
//
// All assets are under CC Attribution Non-Commerical
// http://creativecommons.org/licenses/
//
(function() {
var TIMEOUT = 3000;
var TRANSLATION = 0.05;
var DEFAULT_COLOR = {
red: 237,
green: 220,
blue: 26
};
var INACTIVE_COLOR = {
red: 255,
green: 0,
blue: 0
};
var ACTIVE_COLOR = {
red: 28,
green: 165,
blue: 23
};
var state = false;
var _this = this;
_this.preload = function(entityID) {
_this.entityID = entityID;
};
function restoreDefaultButton() {
var propertiesChanged = {
color: DEFAULT_COLOR
};
Entities.editEntity(_this.entityID, propertiesChanged);
state = false;
}
function disableButton() {
}
_this.mousePressOnEntity = function(entityID, mouseEvent) {
if (!state) {
var propertiesChanged = {
color: ACTIVE_COLOR
};
Entities.editEntity(entityID, propertiesChanged);
}
};
_this.mouseReleaseOnEntity = function(entityID, mouseEvent) {
if (!state) {
state = true;
var propertiesChanged = {
color: INACTIVE_COLOR
};
Entities.editEntity(entityID, propertiesChanged);
Script.setTimeout(function() {
restoreDefaultButton();
}, TIMEOUT);
}
}
});