28 lines
No EOL
1.1 KiB
JavaScript
28 lines
No EOL
1.1 KiB
JavaScript
(function() {
|
|
var DEFAULT_VERTICAL_SPEED = 0.1;
|
|
var DEFAULT_HORIZONTAL_SPEED = 0.05;
|
|
var UPDATE_INTERVAL = 100;
|
|
|
|
this.t = 0;
|
|
var self = this;
|
|
this.preload = function(entityID) {
|
|
self.intervalID = Script.setInterval(function() {
|
|
var verticalSpeed = DEFAULT_VERTICAL_SPEED;
|
|
var horizontalSpeed = DEFAULT_HORIZONTAL_SPEED;
|
|
var userData = JSON.parse(Entities.getEntityProperties(entityID, ["userData"]).userData);
|
|
if (userData !== undefined) {
|
|
if (userData.horizontalScrollSpeed !== undefined) {
|
|
horizontalSpeed = userData.horizontalScrollSpeed;
|
|
}
|
|
if (userData.verticalScrollSpeed !== undefined) {
|
|
verticalSpeed = userData.verticalScrollSpeed;
|
|
}
|
|
}
|
|
Entities.editEntity(entityID, { materialMappingPos: { x: horizontalSpeed * self.t, y: verticalSpeed * self.t }});
|
|
self.t = self.t + UPDATE_INTERVAL / 1000;
|
|
}, UPDATE_INTERVAL);
|
|
};
|
|
this.unload = function() {
|
|
Script.clearInterval(self.intervalID);
|
|
}
|
|
}); |