The Meaning of Life, the Universe, and Everything.
Join Date:
4/7/2016
Posts:
48
Member Details
Here goes the code:
var InGameGUI=false
var Charge=0
var GUI;
function LoadingBar(){
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 directory = new android.graphics.BitmapFactory.decodeFile('/sdcard/DBZIMAGEPACK/LOADINGBAR.png');
var img = new android.graphics.drawable.BitmapDrawable(directory);
var image = new android.widget.ImageView(ctx);
image.setImageBitmap(directory);
image.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(viewarg){
//Your Code Here...
}
});
layout.addView(image);
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.TOP, 0, 0);
}catch(err){
print('An error occured: ' + err);
}
}}));
}
var GUI;
function LoadingBarText(){
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 textview = new android.widget.TextView(ctx);
textview.setTextSize(25);
textview.setText(Charge+'/100');
textview.setGravity(android.view.Gravity.CENTER);
layout.addView(textview);
You are running the code 20 times per second, and it is difficult for most devices to keep recreating the same windows 20 times per second.
Use start(false); to load the "loading" screen the first time. past that, you must use start(true); in order to create the loading screen a second time. syntax is start(boolean); where boolean is manual override allowed or not. as long as you don't use start(true); in a loop, you will be fine. i recommend changing this code to personalize your preferences. you can remove the failsafe by simply removing the first parameter from the start() function, as well as removing the "override" variable from the if conditional within the function.
var InGameGUI=true;
var Charge=0;
var GUI;
function LoadingBar(){
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 directory = new android.graphics.BitmapFactory.decodeFile('/sdcard/DBZIMAGEPACK/LOADINGBAR.png');
var img = new android.graphics.drawable.BitmapDrawable(directory);
var image = new android.widget.ImageView(ctx);
image.setImageBitmap(directory);
image.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(viewarg){
}
});
layout.addView(image);
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.TOP, 0, 0);
}catch(err){
print('An error occured: ' + err);
}
}}));
}
var GUI;
function LoadingBarText(){
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 textview = new android.widget.TextView(ctx);
textview.setTextSize(25);
textview.setText(Charge+'/100');
textview.setGravity(android.view.Gravity.CENTER);
layout.addView(textview);
Here goes the code:
var InGameGUI=false
var Charge=0
var GUI;
function LoadingBar(){
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 directory = new android.graphics.BitmapFactory.decodeFile('/sdcard/DBZIMAGEPACK/LOADINGBAR.png');
var img = new android.graphics.drawable.BitmapDrawable(directory);
var image = new android.widget.ImageView(ctx);
image.setImageBitmap(directory);
image.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(viewarg){
//Your Code Here...
}
});
layout.addView(image);
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.TOP, 0, 0);
}catch(err){
print('An error occured: ' + err);
}
}}));
}
var GUI;
function LoadingBarText(){
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 textview = new android.widget.TextView(ctx);
textview.setTextSize(25);
textview.setText(Charge+'/100');
textview.setGravity(android.view.Gravity.CENTER);
layout.addView(textview);
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.TOP, 0, 0);
}catch(err){
print('An error occured: ' + err);
}
}}));
}
function useItem(x, y, z, itemId, blockId, side)
{
if (itemId==1){
InGameGUI=true
}
}
function newLevel(){
}
function modTick(){
if(InGameGUI==true){
LoadingBarText()
LoadingBar()
}
}
Anyone?
You are running the code 20 times per second, and it is difficult for most devices to keep recreating the same windows 20 times per second.
Use start(false); to load the "loading" screen the first time. past that, you must use start(true); in order to create the loading screen a second time. syntax is start(boolean); where boolean is manual override allowed or not. as long as you don't use start(true); in a loop, you will be fine. i recommend changing this code to personalize your preferences. you can remove the failsafe by simply removing the first parameter from the start() function, as well as removing the "override" variable from the if conditional within the function.
var InGameGUI=true;
var Charge=0;
var GUI;
function LoadingBar(){
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 directory = new android.graphics.BitmapFactory.decodeFile('/sdcard/DBZIMAGEPACK/LOADINGBAR.png');
var img = new android.graphics.drawable.BitmapDrawable(directory);
var image = new android.widget.ImageView(ctx);
image.setImageBitmap(directory);
image.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(viewarg){
}
});
layout.addView(image);
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.TOP, 0, 0);
}catch(err){
print('An error occured: ' + err);
}
}}));
}
var GUI;
function LoadingBarText(){
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 textview = new android.widget.TextView(ctx);
textview.setTextSize(25);
textview.setText(Charge+'/100');
textview.setGravity(android.view.Gravity.CENTER);
layout.addView(textview);
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.TOP, 0, 0);
}catch(err){
print('An error occured: ' + err);
}
}}));
}
function useItem(x, y, z, itemId, blockId, side)
{
}
function newLevel(){
}
function modTick(){
}
function start(override) {
if(InGameGUI==true || override==true){
LoadingBarText();
LoadingBar();
InGameGUI==false;
}
}
I have nothing to say...