Hi All, Have anyone figured out a way to set an event observer for a distance covered by the character? I would be really grateful for those who could help. Thanks Wiss
there is no event observer. you can use this code for distance. let dist = this.scene().path().pathPosition(); //distance log(Math.round(dist));
let dist = this.scene().path().pathPosition(); //distance this.entity().component('Label').setText(String(Math.round(dist)));
Wow! Thank you. Very useful post. - 2D text on screen - UI buttons with click handlers - Settings object Curious where you found this functionality. Is this from BuildBox2 or is this from the templates? I don't see any of this listed in the API.
I'd like to see a follow up to this, showing how to find a Label from the Game UI, and assign the dist value to it, instead of it being a component. I have already attempted this in update: Code: let dist = this.scene().path().pathPosition(); let _distanceLabel = this.ui().find('Distance')[0]; log(_distanceLabel.text()); _distanceLabel.setText(String(Math.round(dist))); Thanks -Larry
Does anyone know how I can change the "undefined" and "NaN" text to the level numbers? Also, how do I make the progress bar finish right as a level is complete? Thanks
how can i change the way that the distance are being numbered like its too quick i reached only 10 scenes and im on 33875 something like this can someone help?? and i removed the log(Math.round(dist)); and its suppose to make my game run smoother but i think its not help so much.
Many thanks to you brother and another thing how can i present in game ui my best distance that i have reached?
in UI add an asset and add a label inside for best score, you can create another global var. use if dist>bestdist update bestdist
i put all of this let dist = this.scene().path().pathPosition(); //distance this.entity().component('Label').setText(String(Math.round(dist))); with the label node near this code added math.round(dist)/100 i exported this as an asset and copy it into the ui but i cant see nothing its not show me the distance please help thanks
Hi, I tried downloading your distance working project but the link shows another project called jump-shoot can you please send me a link to your distance project? Many Thanks
this is the code thats working function init(){ } function update(dt){ let dist = this.scene().path().pathPosition(); this.entity().component('Label').setText(String(Math.round(dist/100))); } function signal(name, value) { }
function init(){ } function update(dt,bestdist='0'){ let dist = this.scene().path().pathPosition(); let bestdist = this.scene().path().pathPosition(); this.entity().component('Label2').setText(String(Math.round(dist/100))); if(bestdist==null){ } else(dist>bestdist){ bestdist.update; } } function signal(name, value) { } how do i make this like a total coin or somthing like that how can i save the best distance after i close the game?