In this video, we are adding monsters, which you can kill, if you jump on it. And lootbox, which can be destroyed like in Super Mario, and it drops gun. When gun is collected, shoot button and animations comes visible.
Download BB DOC file: https://www.hanomaxgames.com/Downloads/platformer3.bbdoc
First Script node’s code:
function init(){
if(Settings.power == undefined){
Settings.power = 0;
}
if(Settings.power == 0) {
this.emitSignal('poweron', false);
this.emitSignal('poweroff', true);
this.entity().component('Run2').setVisible(false);
this.entity().component('Idle2').setVisible(false);
this.entity().component('Jump2').setVisible(false);
this.ui().find('shoot')[0].setVisible(false);
}
else {
this.emitSignal('poweron', true);
this.emitSignal('poweroff', false);
this.entity().component('Run1').setVisible(false);
this.entity().component('Idle1').setVisible(false);
this.entity().component('Jump1').setVisible(false);
}
}
function start(){
}
function update(dt){
}
function signal(name, value) {
if (name =='Trigger' && value) {
if (Settings.power == 1) {
this.emitSignal('poweron', true);
this.emitSignal('poweroff', false);
this.entity().component('Run1').setVisible(false);
this.entity().component('Idle1').setVisible(false);
this.entity().component('Jump1').setVisible(false);
this.ui().find('shoot')[0].setVisible(true);
this.entity().component('Run2').setVisible(true);
this.entity().component('Idle2').setVisible(true);
this.entity().component('Jump2').setVisible(true);
}
else {
this.emitSignal('poweron', false);
this.emitSignal('poweroff', true);
this.entity().component('Run2').setVisible(false);
this.entity().component('Idle2').setVisible(false);
this.entity().component('Jump2').setVisible(false);
this.ui().find('shoot')[0].setVisible(false);
this.entity().component('Run1').setVisible(true);
this.entity().component('Idle1').setVisible(true);
this.entity().component('Jump1').setVisible(true);
}
}
}
Second Script node’s code:
function init(){
}
function start(){
}
function update(dt){
}
function signal(name, value){
if(name = 'Enabled' && value) {
if (value && this.entity().scale().x == 1) {
this.emitSignal('right', true);
}
if (value && this.entity().scale().x == -1) {
this.emitSignal('left', true);
}
}
}