Just a little post from me to say I developed a really useful script last night:
https://playcanvas.com/editor/asset/5298060
It allows you to define clickable rectangular regions that fire events.
The script UI in the Editor is:
The box attribute defines the size and shape of the clickable region. The first two numbers are the coordinate of the bottom left corner of the box. The second two numbers are the width and height of the box. The box values are between 0 and 1, where a y value of 0 is the bottom of the screen and 1 is the top.
The debug attribute controls whether an outline of the defined region is rendered in the game, to help you place it. For example:
The event attribute controls the name of the event fired from the app. So if you set this to ‘myevent’, you handle it anywhere in your game’s scripts with:
this.app.on('myevent', function () {
console.log('Wow, this script is freaking awesome!');
});
Obviously, the main use case is triggering behavior on selecting screen areas - so UI buttons. Hope you find it useful!