Slide button based on "User Interface - Stats Counter"

Hello all,

I want to study of how to create slide button,

For the main lesson I choose this scene

User Interface - Stats Counter | Learn PlayCanvas,

My idea is to insert a group of buttons (+/- and progress bar) into my project PlayCanvas | HTML5 Game Engine , and after instead of progress bar insert my sliding button…

So, now I have probelms with inserting progress button in my scene, can`t to figure out why I have this mistake, maybe someone could help me!?

Hello @Ivan_Stratiichuk,

this.progressBar.script.progressBar.setProgress(this.value / 10);

There is no progressBar script on your progressBar entity, so that gives an error. I only see a slidebutton script, but i can’t find that script in your project.

If you have changed the name of the script try to use the parse button on the progressBar entity to update the script name.

1 Like

Hey @Ivan_Stratiichuk,

This is certainly a parsing issue.

Little mistake here @Albertos. @Ivan_Stratiichuk should parse the Button Group entity, and select the progress bar entity. I don’t think this is a script naming issue, rather which entity to parse. Attributes can be quite confusing though :smiley:.

@Ivan_Stratiichuk, it’d help you a lot if you took a look at the attributes tutorial.

If you need help understanding progress bars, feel free to check out my game Shifty - which uses progress bars to a large extent - https://playcanvas.com/editor/scene/843343.

Hope this is helpful.

What is my mistake? I feel like you’re saying the same thing but explaining it differently.

Hello people,

It works, it was a parse mistake!

Now trying to insert this buttons into my progressbar…

Great! I understand what you are trying to do. I think it is not difficult. But I foresee the problem that the scene will be switched when you are still clicking to the right scene…

You said that the progress bar should be parsed, instead the button group had the script, and it should be parsed instead.

No the Buttons Group has ony the script uiStats.

1 Like

Exactly. The error was in uiStats.

Because there was a problem with the script on the progressBar entity.

I don’t think that was the issue. The issue was that it couldn’t find any entity called this.ProgressBar, meaning the progress bar entity hadn’t been parsed on to uiStats. The solution to this was parsing the progress bar entity on the uiStats script, which existed only in button group.

Nope. The problem was the script progressBar was undefided because the script name was not updated on the progressBar entity.

2 Likes

I didn`t update the name of progress bar script, after parsing it began to work…

Ok, my bad. When I tried reproducing the error, that was not what happened. Thanks for the explanation @Albertos.

Could you help me to figure out of how to insert buttons into progressbar, I tried to do it but it don`t work…!?

Of course! But I’m on mobile right now so my options are limited.

I will ask, and try to understand what do you mean…

So to insert buttons to progressbar I need to use names of buttons and insert them into progressbar code, am I right?

I think if you want to use your progressBar to switch between scenes you don’t need the buttons anymore. Just check the current number after the player has using it and switch to that scene.

Note: I foresee the problem that the scene will be switched when the player is still clicking to the right scene. So you need also a timer or something. Also I think progressBar is not the best name, because it is not a progress bar?

Yes, its not a progress bar, but I dont want to change the name not to make a mistakes…

I thought to build the next:
I will have a group of buttons, left arrow, middle slide button and right arrow. When user want to change a scene he need to chose those scene that he want by arrow, and after he did it to click on middle slide button, thats why I choose progress bar code as a base…!?

Yes, that’s the best way indeed!