Really need help , never used gui so how do I put my code into the gui like after the button is pressed ot does what I want and after I pull up the menu Nd hit a button the menu goes way !!
var GUI;
var menu;
var pack = true;
function newLevel(){
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
ctx.runOnUiThread(new java.lang.Runnable({ run: function(){
try{
var layout = new android.widget.LinearLayout(ctx);
layout.setOrientation(1);
var menuBtn = new android.widget.Button(ctx);
menuBtn.setText("Mod Pack");
menuBtn.setOnClickListener(new android.view.View.OnClickListener({
onClick: function(viewarg){
mainMenu();
}
}));
layout.addView(menuBtn);
GUI = new android.widget.PopupWindow(layout, android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT, android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
GUI.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.TRANSPARENT));
GUI.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.LEFT | android.view.Gravity.CENTER, 0, 0);
}catch(err){
print("An error occured: " + err);
}
}}));
}
function mainMenu(){
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
ctx.runOnUiThread(new java.lang.Runnable({ run: function(){
try{
var menuLayout = new android.widget.LinearLayout(ctx);
var menuScroll = new android.widget.ScrollView(ctx);
var menuLayout1 = new android.widget.LinearLayout(ctx);
menuLayout.setOrientation(1);
menuLayout1.setOrientation(1);
menuScroll.addView(menuLayout);
menuLayout1.addView(menuScroll);
var button = new android.widget.Button(ctx);
button.setText(" Galactic Pack");
button.setOnClickListener(new android.view.View.OnClickListener({
onClick: function(viewarg){
function useItem(x,y,z,itemId,blockId,side)
{
if(pack = true) //if u tap wooden plank with an iron sword
{
setTile(x,y-1,z,9)
}
}
}
}));
menuLayout.addView(button);
//Add more buttons in this section
menu = new android.widget.PopupWindow(menuLayout1, ctx.getWindowManager().getDefaultDisplay().getWidth()/2, ctx.getWindowManager().getDefaultDisplay().getHeight());
menu.setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(android.graphics.Color.BLACK));
menu.showAtLocation(ctx.getWindow().getDecorView(), android.view.Gravity.RIGHT | android.view.Gravity.TOP, 0, 0);
}catch(error){
print("An error occured: " + error);
}
}}));
}
function leaveGame(){
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
ctx.runOnUiThread(new java.lang.Runnable({ run: function(){
if(GUI != null){
GUI.dismiss();
GUI = null;
}
if(menu != null){
menu.dismiss();
menu = null;
}
}}));
}
That's my GUI template on my GitHub wiki isn't it? Do you want me to add an "exit" button to the template? Also, you can't initiate the useItem() hook after onClick.
That's my GUI template on my GitHub wiki isn't it? Do you want me to add an "exit" button to the template? Also, you can't initiate the useItem() hook after onClick. You have a kik ? If so kik me db_mack asap , or reply to my pm
Want GUI Templates? Done!
https://github.com/BeATz-UnKNoWN/ModPE_Scripts/wiki/ModPE-Script-Templates
P.S. Feel free to follow me so you know when I post "awesome" content and make the MCForums a brighter place (totally).
If you need to contact me you can either shoot a Kik message to beatz_unknown or send an email to [email protected]