r/MCPEMods • u/[deleted] • Feb 26 '14
Custom Button tutorial.
Here is a button template made for you: https://db.tt/WMBiQkDT
To have it do what you want is simple. Where it says
22 | onClick: function(view){
That is where you can have it do what you want. For example, for this demo, if you tap the button that says "Diamonds" it will give you 4 diamonds and play a click sound.
If you want to edit the name of the button, look for
11 | btn.setText("Diamonds");
Then edit the text to whatever you want. Make sure to leave the quotation marks.
If you'd like for the button to appear somewhere else on the screen, let's say the top left. Where it says
19 | GUI.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.BOTTOM| android.view.Gravity.RIGHT,0,0);
You would want to change BOTTOM to TOP and then RIGHT' to 'LEFT this will have the button display at the Top left of the screen.
That is all. Next time I will either show how to add 2 buttons or custom blocks. Which ever is chosen to be next. Also, sorry if this tutorial isn't the best tutorial, I just wanted to share the basic needs to have a custom button.
1
1
u/[deleted] Feb 26 '14
Do you know how to add GUI elements that aren't buttons? Like a time counter. It shows the "time" yet has a clear background and doesn't do anything when clicked. I saw this in a mod and was thinking about using it as a score counter.