Button private exposed variable

The bulk of the explanation is here: How do i edit the Create function to add params to constructor?

The corrected script is here:

var Button = pc.createScript('button');
Button.attributes.add('shift', {type: 'number'});

// initialize code called once per entity
Button.prototype.initialize = function() {
    this.entity.button.on('click', this.onRelease, this); 
};

Button.prototype.onRelease = function () {
    this.app.fire('game:Next', this.shift);
};
1 Like