Вот код:
Код: Выделить всё
class ProjectMain
{
init() {
this.goButton = nc.addButton( nc.graphicAssets.go, nc.mainScene, "Go" );
this.stopButton = nc.addButton( nc.graphicAssets.stop, nc.mainScene, "Stop" );
// initially the stop button is not visible
this.stopButton.visible = false;
// add the press callback to the buttons
this.goButton.addPressCallback( this, "onPress", ["Go"] );
this.stopButton.addPressCallback( this, "onPress", ["Stop"] );
}
onPress( event, camera, action ) {
console.log(action); // this is always Stop??
//toggle visibility
if ( "Go" == action ) {
this.stopButton.visible = true;
this.goButton.visible = false;
} else {
this.stopButton.visible = false;
this.goButton.visible = true;
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... s-expected