var Button = pc.createScript('button');
Button.attributes.add('shift', {type: 'number'});
var self;
var jumpBy;
// initialize code called once per entity
Button.prototype.initialize = function() {
self = this;
jumpBy = self.shift;
self.entity.button.on('click', this.onRelease, this);
};
// update code called every frame
Button.prototype.update = function(dt) {
};
Button.prototype.onRelease = function () {
self.app.fire('game:Next', jumpBy);
};
I’ve made a nice little button and exposed the jump param so i can control it externally.
however, i figured out that this variable is global
if I have few buttons in the scene and each has a different number, the value of the top-most button in the hierarchy will prevail and ALL buttons will be redefined to that value.
how can I create a value that will be different per instance?