In the below code I am tryin to pass sensor values from Frag1 to Frag2
through the mainActivity. Frag1 implements sensorEvenListener and in Frag1's onResume i pass the values to the mainActivtiy by sendValues.onSendValues(getAccX(), getAccY(), getAccZ()); the sendValues is an object of the interface called onSendListener which is implemented in the mainActivity.
In the MainActivity I pass the data to Frag2 using
#Override
public void onSendValues(float x, float y, float z) {
// TODO Auto-generated method stub
Bundle b = new Bundle();
b.putFloat("x", x);
b.putFloat("y", y);
b.putFloat("z", z);
Frag2 frag2 = new Frag2();
frag2.setArguments(b);
}
as shown below in the code.
the problem is, when i check if the bundle sent to Frag2 is null or not, i find it is null, why it is null?
please find the code posted below
** MainActivity**:
public class MainActivity extends Activity implements onSendListener {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
}
/**
* to send values from frag1 to frag2 through mainActivity. use bundle.
*/
#Override
public void onSendValues(float x, float y, float z) {
// TODO Auto-generated method stub
Bundle b = new Bundle();
b.putFloat("x", x);
b.putFloat("y", y);
b.putFloat("z", z);
Frag2 frag2 = new Frag2();
frag2.setArguments(b);
}
}
**Frag1 **:
public class Frag1 extends Fragment implements SensorEventListener {
private SensorManager sensorManager;
TextView tvAccX;
TextView tvAccY;
TextView tvAccZ;
private float x = 0.0f;
private float y = 0.0f;
private float z = 0.0f;
private void setAccX(float x) {
this.x = x;
}
private float getAccX() {
return this.x;
}
private void setAccY(float y) {
this.y = y;
}
private float getAccY() {
return this.y;
}
private void setAccZ(float z) {
this.z = z;
}
private float getAccZ() {
return this.z;
}
Button btnSend;
onSendListener sendValues;
#Override
public void onAttach(Activity activity) {
// TODO Auto-generated method stub
super.onAttach(activity);
sendValues = (onSendListener) activity;
sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
View view = inflater.inflate(R.layout.frag_1, container, false);
tvAccX = (TextView) view.findViewById(R.id.tv_accX_value);
tvAccY = (TextView) view.findViewById(R.id.tv_accY_value);
tvAccZ = (TextView) view.findViewById(R.id.tv_accZ_value);
btnSend = (Button) view.findViewById(R.id.btn_send);
return view;
}
#Override
public void onViewCreated(View view, Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onViewCreated(view, savedInstanceState);
}
#Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
switch (event.sensor.getType()) {
case Sensor.TYPE_ACCELEROMETER:
showAccReadings(event);
break;
default:
break;
}
}
private void showAccReadings(SensorEvent event) {
// TODO Auto-generated method stub
float[] values = event.values;
float x = values[0];
float y = values[1];
float z = values[2];
setAccX(x);
setAccY(y);
setAccZ(z);
tvAccX.setText(String.valueOf(x));
tvAccY.setText(String.valueOf(y));
tvAccZ.setText(String.valueOf(z));
}
#Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
#Override
public void onResume() {
// TODO Auto-generated method stub
super.onResume();
Sensor accSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
sensorManager.registerListener(this, accSensor, sensorManager.SENSOR_DELAY_FASTEST);
btnSend.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
sendValues.onSendValues(getAccX(), getAccY(), getAccZ());
}
});
}
#Override
public void onPause() {
// TODO Auto-generated method stub
super.onPause();
sensorManager.unregisterListener(this);
}
}
**Frag2 **:
public class Frag2 extends Fragment {
float x;
float y;
float z;
TextView tvX;
TextView tvY;
TextView tvZ;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
x = getArguments().getFloat("x");
y = getArguments().getFloat("y");
z = getArguments().getFloat("z");
View view = inflater.inflate(R.layout.frag_2, container, false);
tvX = (TextView) view.findViewById(R.id.tv_accX2_label);
tvY = (TextView) view.findViewById(R.id.tv_accY2_label);
tvZ = (TextView) view.findViewById(R.id.tv_accZ2_label);
return view;
}
#Override
public void onViewCreated(View view, Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onViewCreated(view, savedInstanceState);
if (getArguments() != null) {
Log.d("Frag2", "getArgument() is not NULL");
x = getArguments().getFloat("x");
y = getArguments().getFloat("y");
z = getArguments().getFloat("z");
} else {
Log.d("Frag2", "getArgument() is NULL");
}
tvX.setText(String.valueOf(x));
tvY.setText(String.valueOf(y));
tvZ.setText(String.valueOf(z));
}
}
** mainActivity.xml**:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="${relativePackage}.${activityClass}">
<fragment
android:name="com.example.fragmentcommunication_00.Frag1"
android:id="#+id/frag_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"/>
<fragment
android:name="com.example.fragmentcommunication_00.Frag2"
android:id="#+id/frag_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_centerHorizontal="true"
android:layout_below="#id/frag_1"/>
You have two Frag2 in your code.
This first one is created during the inflation time of your mainActivity.xml, and no arguments is passed to it when its onCreateView or onViewCreated method is executed.
The second one is instantiated in your code as following:
Frag2 frag2 = new Frag2();
frag2.setArguments(b);
Thus the argument you set here has nothing to do with the prior one that is attached to your Activity.
Here is the solution to you problem:
Add a public method to your Frag2 class as following:
public void passValues(float x, float y, float z){
this.x = x;
this.y = y;
this.z = z;
View view = getView();
if(view != null){
// set the value to views here.
}
}
Change the onSendValues method in your MainActivity as following:
#Override
public void onSendValues(float x, float y, float z) {
Frag2 frag2 = (Frag2)getFragmentManager().findFragmentById (R.id.frag_2);
frag2.passValues(x, y, z);
}
Related
I am trying to communicate dynamically between two fragments. Frag1 imlements sensorlistener and passes the values to the mainActivity.
the mainActivity implements onSendListener.onSendValues interface. in the implementation of onSendValues in the mainActivity, when the user clicks the button defined in Frag1, I pass the values of the Accelerometer (x,y,z) received from Frag1 to the Frag2 through the mainActivityby accessing Frag2's public methods
void returnedX(float x) {...}
void returnedY(float y) {...}
void returnedZ(float z) {...}
what happens is, when the user clicks the button in Frag1, the textViews in Frag2 displays nothing despite their public methods
void returnedX(float x) {...}
void returnedY(float y) {...}
void returnedZ(float z) {...}
are called, i am sure they were called because as shown below in the code, the Log statements in the public methods in Frag2 is displayed but the values of the acceöerometer not.
please see below the code, and let me know why the public methods in Frag2 do not display the passed date from Frag1
MainActivity:
public class MainActivity extends Activity implements onSendListener {
Frag2 frag2;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
frag2 = (Frag2)getFragmentManager().findFragmentById (R.id.frag_2);
}
/**
* to send values from frag1 to frag2 through mainActivity. use bundle.
*/
#Override
public void onSendValues(float x, float y, float z) {
// TODO Auto-generated method stub
frag2.returnedX(x);
frag2.returnedY(y);
frag2.returnedZ(z);
}
}
Frag1:
public class Frag1 extends Fragment implements SensorEventListener {
private SensorManager sensorManager;
TextView tvAccX;
TextView tvAccY;
TextView tvAccZ;
private float x = 0.0f;
private float y = 0.0f;
private float z = 0.0f;
private void setAccX(float x) {
this.x = x;
}
private float getAccX() {
return this.x;
}
private void setAccY(float y) {
this.y = y;
}
private float getAccY() {
return this.y;
}
private void setAccZ(float z) {
this.z = z;
}
private float getAccZ() {
return this.z;
}
Button btnSend;
onSendListener sendValues;
#Override
public void onAttach(Activity activity) {
// TODO Auto-generated method stub
super.onAttach(activity);
sendValues = (onSendListener) activity;
sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
View view = inflater.inflate(R.layout.frag_1, container, false);
tvAccX = (TextView) view.findViewById(R.id.tv_accX_value);
tvAccY = (TextView) view.findViewById(R.id.tv_accY_value);
tvAccZ = (TextView) view.findViewById(R.id.tv_accZ_value);
btnSend = (Button) view.findViewById(R.id.btn_send);
return view;
}
#Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
switch (event.sensor.getType()) {
case Sensor.TYPE_ACCELEROMETER:
showAccReadings(event);
break;
default:
break;
}
}
#Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
private void showAccReadings(SensorEvent event) {
// TODO Auto-generated method stub
float[] values = event.values;
float x = values[0];
float y = values[1];
float z = values[2];
setAccX(x);
setAccY(y);
setAccZ(z);
tvAccX.setText(String.valueOf(x));
tvAccY.setText(String.valueOf(y));
tvAccZ.setText(String.valueOf(z));
}
#Override
public void onResume() {
// TODO Auto-generated method stub
super.onResume();
Sensor accSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
sensorManager.registerListener(this, accSensor, sensorManager.SENSOR_DELAY_FASTEST);
btnSend.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
sendValues.onSendValues(getAccX(), getAccY(), getAccZ());
}
});
}
#Override
public void onPause() {
// TODO Auto-generated method stub
super.onPause();
sensorManager.unregisterListener(this);
}
}
Frag2:
public class Frag2 extends Fragment {
TextView tvX;
TextView tvY;
TextView tvZ;
float returnX ;
float returnY ;
float returnZ ;
void returnedX(float x) {
if (getView() != null) {
Log.d("Frag2", "X: View is not null");
this.returnX = x;
}
}
void returnedY(float y) {
if (getView() != null) {
Log.d("Frag2", "Y: View is not null");
this.returnY = y;
}
}
void returnedZ(float z) {
if (getView() != null) {
Log.d("Frag2", "Z: View is not null");
this.returnZ = z;
}
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
// TODO Auto-generated method stub
View view = inflater.inflate(R.layout.frag_2, container, false);
tvX = (TextView) view.findViewById(R.id.tv_accX2_label);
tvY = (TextView) view.findViewById(R.id.tv_accY2_label);
tvZ = (TextView) view.findViewById(R.id.tv_accZ2_label);
return view;
}
#Override
public void onViewCreated(View view, Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onViewCreated(view, savedInstanceState);
Log.d("Frag2", "View is not null");
tvX.setText("" + this.returnX);
tvY.setText("" + this.returnY);
tvZ.setText("" + this.returnZ);
}
}
Log Output:
01-26 13:03:36.876: D/Frag2(16146): X: View is not null
01-26 13:03:36.876: D/Frag2(16146): Y: View is not null
01-26 13:03:36.876: D/Frag2(16146): Z: View is not null
You need to set the actual value to the TextViews
void returnedX(float x) {
if (tvX != null) {
tvX.setText("" + x);
}
}
I want to implement interactive TabPageIndicatot in android. I am using ViewPager.TabPageIndicator to make object of indicator.I am trying to implement scrollTo in TabPageIndicator class.
This is the code in my class. indicator is object of TabPageIndicator.
public void onPageScrolled(int pageNo, float arg1, final int arg2) {
// TODO Auto-generated method stub
indicator.scrollTo(arg2, 0);
}
This is the code in TabPageIndicator class.
private void animateToTab(final int x) {
if (mTabSelector != null) {
removeCallbacks(mTabSelector);
}
mTabSelector = new Runnable() {
public void run() {
// final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2;
smoothScrollTo(x, 0);
mTabSelector = null;
}
};
post(mTabSelector);
}
#Override
public void scrollTo(int x, int y) {
// TODO Auto-generated method stub
super.scrollTo(x, y);
//Log.i("Hi", Integer.toString(x));
animateToTab(x);
}
Here animateToTab() function is called infinite times. Why?
Hi im having a bit of problems getting my sprite to fade back in. Im using paralell entity modifiers, scaling and fading after which the sprite gets new X and Y cordinates and fades in and scales back up. It doesnt work and i think it might have something to do with the onUpdate method.
XOsprite = new Sprite(x, y, XO, engine.getVertexBufferObjectManager()) {
#Override
public boolean onAreaTouched(final TouchEvent te, final float xVal,
final float yVal) {
XOsprite.registerEntityModifier(downOut); //kill sprite
isKilled = true;
XOsprite.registerUpdateHandler(new IUpdateHandler() {
#Override
public void reset() {
// TODO Auto-generated method stub
}
#Override
public void onUpdate(float pSecondsElapsed) {
// TODO Auto-generated method stub
totalElapsedTime += pSecondsElapsed;
if(totalElapsedTime >= 3.0f){
BaseGameActivity gameActivity = (BaseGameActivity) activity;
gameActivity.runOnUpdateThread(new Runnable() {
#Override
public void run() {
// TODO Auto-generated method stub
if(isKilled){
reviveSprite();
isKilled = false;
}
}
});
}
//reset();
}
});
return true;
}
};
XOsprite.registerEntityModifier(inUp);
gameScene.attachChild(XOsprite);
gameScene.registerTouchArea(XOsprite);
return gameScene;
}
-edit- more code
public void reviveSprite(){
setSprites();
XOsprite.unregisterEntityModifier(downOut);
XOsprite.registerEntityModifier(inUp);
}
public void setSprites(){
if (rand.nextInt(2) == 0) {
XO = X;
} else {
XO = O;
}
x = rand.nextInt(MainActivity.CAM_WIDTH);
y = rand.nextInt(MainActivity.CAM_HEIGHT);
}
you are already on the UpdateThread, so no need to do this
gameActivity.runOnUpdateThread(new Runnable() {
#Override
public void run() {
// TODO Auto-generated method stub
if(isKilled){
reviveSprite();
isKilled = false;
}
}
});
just do this
if(isKilled){
reviveSprite();
isKilled = false;
}
I had created dynamic line graph using AChartEngine Api, which shows the changes in G-Force value. All works fine but when graph moves ahead in X-axis i have to manually scroll in X-axis to see it further, please check my image below if you are not getting me properly.
how can i make it auto scrollable in x-axis to avoid manually scrolling?
Following is my code
public class GraphActivity extends Activity implements SensorEventListener{
private LinearLayout lyGforce;
//=== G-force =======
private SensorManager mSensorManager;
private Sensor mAccelerometer;
private float gOffset;
private boolean calibrate;
private static TimeSeries timeSeriesGforce;
private static XYMultipleSeriesDataset datasetGforce;
private static XYMultipleSeriesRenderer rendererGforce;
private static XYSeriesRenderer rendererSeriesGforce;
private static GraphicalView viewGforce;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.mainactivity);
lyGforce = (LinearLayout) findViewById(R.id.lygforce);
//=========== G-force =======
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
datasetGforce = new XYMultipleSeriesDataset();
rendererGforce = new XYMultipleSeriesRenderer();
rendererGforce.setApplyBackgroundColor(true);
rendererGforce.setBackgroundColor(Color.argb(100, 50, 50, 50));
rendererGforce.setAxisTitleTextSize(16);
rendererGforce.setChartTitleTextSize(20);
rendererGforce.setLabelsTextSize(15);
rendererGforce.setLegendTextSize(15);
rendererGforce.setMargins(new int[] { 20, 30, 15, 0 });
rendererGforce.setZoomButtonsVisible(true);
rendererGforce.setPointSize(10);
rendererGforce.setShowGrid(true);
rendererGforce.setGridColor(Color.WHITE);
rendererSeriesGforce = new XYSeriesRenderer();
rendererSeriesGforce.setColor(Color.GREEN);
rendererSeriesGforce.setLineWidth(2);
rendererGforce.addSeriesRenderer(rendererSeriesGforce);
timeSeriesGforce = new TimeSeries("G-Force");
datasetGforce.addSeries(timeSeriesGforce);
viewGforce = ChartFactory.getTimeChartView(this, datasetGforce, rendererGforce, "");
viewGforce.refreshDrawableState();
viewGforce.repaint();
lyGforce.addView(viewGforce);
}
#Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
// ============= G-force ==================//
calibrate = true;
mSensorManager.registerListener(this, mAccelerometer,
SensorManager.SENSOR_DELAY_UI);
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
//========== G-force=============//
mSensorManager.unregisterListener(this);
}
#Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
//========== G-force=============//
#Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
switch (event.sensor.getType()) {
case Sensor.TYPE_ACCELEROMETER:
float x = event.values[0];
float y = event.values[1]; // Use to calculate G-Force value
float z = event.values[2];
if(calibrate)
gOffset = y - SensorManager.GRAVITY_EARTH;
double gForce = ((y - gOffset) / SensorManager.GRAVITY_EARTH);
timeSeriesGforce.add(new Date(), gForce);
rendererGforce.setXAxisMax(rendererGforce.getXAxisMax() + 30);
rendererGforce.setXAxisMin(rendererGforce.getXAxisMin() + 30);
viewGforce.repaint();
Log.e("NIRAV","G-Force: "+String.valueOf(gForce));
calibrate = false;
break;
default:
break;
}
}
}
You can do this by changing the visible area on the X axis:
renderer.setXAxisMin(min);
renderer.setXAxisMax(max);
i developed a map who can rotate the direction view depend where the user face (example, if the user turn into south,than map will rotating to south direction, like compass). I already tried this project with minimal success for a couple week. I have no error message on eclipse,but when i debug the code, the application always crash.
Thanks,i really need all the help
private class RotateView extends ViewGroup {
private Matrix mMatrix = new Matrix();
private float[] mTemp = new float [2];
private static final float SQ2 = 1.414213562373095f;
public RotateView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
#Override
protected void dispatchDraw(Canvas canvas) {
// TODO Auto-generated method stub
canvas.save(Canvas.MATRIX_SAVE_FLAG);
canvas.rotate(-mHeading,getWidth()*0.5f , getHeight()*0.5f);
canvas.getMatrix(mMatrix);
super.dispatchDraw(canvas);
canvas.restore();
}
#Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// TODO Auto-generated method stub
final int width = getWidth();
final int height = getHeight();
final int count = getChildCount();
for (int i=0; i<=count; i++){
final View view = getChildAt(i);
final int childWidth = view.getMeasuredWidth();
final int childHeight = view.getMeasuredHeight();
final int childLeft = ((width - childWidth)/2);
final int childTop = ((height-childHeight)/2);
view.layout(childLeft, childTop, childLeft+childWidth, childTop+childHeight);
}
}
#Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// TODO Auto-generated method stub
int mW = getDefaultSize(getMeasuredWidth(), widthMeasureSpec);
int mH = getDefaultSize(getMeasuredHeight(), heightMeasureSpec);
int sizeSpec;
if(mW > mH){
sizeSpec = MeasureSpec.makeMeasureSpec((int)(mW*SQ2), MeasureSpec.EXACTLY);
} else {
sizeSpec = MeasureSpec.makeMeasureSpec((int) (mH*SQ2), MeasureSpec.EXACTLY);
}
final int count = getChildCount();
for(int i = 0; i<count; i++){
getChildAt(i).measure(sizeSpec, sizeSpec);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
#Override
public boolean dispatchTouchEvent(MotionEvent e) {
// TODO Auto-generated method stub
return super.dispatchTouchEvent(e);
}
}
// End of class RotateView
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sensormanager =(SensorManager)getSystemService(SENSOR_SERVICE);
rotateview = new RotateView(this);
map = new MapView (this,"Map Key");
rotateview.addView(map);
setContentView(rotateview);
controll();
}
public void controll () {
controller = map.getController();
//Zoom
map.setBuiltInZoomControls(true);
controller.setZoom(19);
overlayList = map.getOverlays();
map.setClickable(true);
map.setEnabled(true);
//compass
compass = new MyLocationOverlay(MapIpbActivity.this, map);
overlayList.add(compass);
myLocation();
Touchy t = new Touchy();
overlayList.add(t);
}
public void myLocation() {
ourLocation = new MyLocationOverlay(MapIpbActivity.this, map);
map.getOverlays().add(ourLocation);
ourLocation.runOnFirstFix(new Runnable() {
public void run(){
controller.animateTo(ourLocation.getMyLocation());
}
});
}
#Override
protected void onPause() {
// TODO Auto-generated method stub
compass.disableCompass();
ourLocation.disableMyLocation();
sensormanager.unregisterListener(orientListener);
super.onPause();
}
#Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
compass.enableCompass();
ourLocation.enableMyLocation();
sensormanager.registerListener(orientListener,
sensormanager.getDefaultSensor(Sensor.TYPE_ORIENTATION),
sensormanager.SENSOR_DELAY_NORMAL);
}
final SensorEventListener orientListener = new SensorEventListener() {
#Override
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
if(event.sensor.getType() == Sensor.TYPE_ORIENTATION){
mHeading = event.values[0];
rotateview.invalidate();
}
}
#Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
// TODO Auto-generated method stub
}
};
class Touchy extends Overlay {
long start;
long stop;
int x;
int y;
GeoPoint TouchedPoint;
#Override
public boolean onTouchEvent(MotionEvent e, MapView m) {
// TODO Auto-generated method stub
if(e.getAction() == MotionEvent.ACTION_DOWN) {
start = e.getEventTime();
x = (int) e.getX();
y = (int) e.getY();
TouchedPoint = map.getProjection().fromPixels(x, y);
}
if (e.getAction() == MotionEvent.ACTION_UP) {
stop = e.getEventTime();
}if (stop - start > 2000){
box();
return true;
}
return false;
}
Solved this, just change i<=count into i<count, and everything will work! But my zoom and compass didn't show.