android - If object reaches the edge of the canvas, open a new activity. How do I do this? -


This code is from the rest of the tutorial from the newboston website 128. Please view it as necessary.

If the green ball kills the edges of the canvas, then I want it to open a new activity. How do I write this process?

Public-class accelerating activity implementation sensor avenger listener {

  float x, y, sensor, sensor; Float alpha; Bitmap ball; Sensor Manager SAM; MyBeingbackForphs Our Surface View; Public Class MyBringBackSurface SurfaceView implements Runnable {SurfaceHolder ourHolder; Thread ourThread = null; Boolean isRunning = false; Public MyBringBackSurface (Reference Reference) {// TODO Automatically Generated Producer, Super (Reference); OurHolder = getHolder (); } Public Zero Break () {isRunning = false; While {true} {try {ourThread.join (); } Grip (Interrupted E) E. {// TODO Auto-Generated Catch Block e.printStackTrace (); }             break; } OurThread = null; } Public resume from zero () {isRunning = true; Our thread = new thread (this); OurThread.start (); } @ Override Public Wide Run () {// Tudo Auto-Generated Math Stub, while (Irining) {if (Our! Hollder.GetSfFF.) IsValid () is on; Canvas canvas = ourHolder.lockCanvas (); //canvas.draw RGB (2, 2, 100); Blue Canvas Left RGB (227, 168, 105); // mango peach // float center x = canvas.get wyeth () / 2; // float center y = canvas.getight () / 2; Float centerX = (canvas.getWidth () - ball.getWidth ()) / 2; Float center Y = (canvasgatehit () - ball.getHeight ()) / 2; Canvas.drawBitmap (ball, center area + sensor X * 20, center Y + sensor * 20, empty); OurHolder.unlockCanvasAndPost (canvas); }}} @ Override protected zero creation (InstanceStatus saved from bundle) {// Tudro auto-generated method stub super. Connet (Saved Instantstate); Sm = (sensor manager) getSystemService (Context.SENSOR_SERVICE); If (sm.getSensorList (sensor.TYPE_ACCELEROMETER). Size ()! = 0) {censor s = sm.getSensorList (sensor.TYPE_ACCELEROMETER) .get (0); Sm.registerListener (this, s, sensor manager.SENSOR_DELAY_NORMAL); } Ball = BitMapficht. Decode processing (getResources (), R.drawable.greenball); X = y = sensor X = sensor Y = 0; OurSurfaceView = New MyBringBackSurface (this); OurSurfaceView.resume (); SetContentView (ourSurfaceView); } @ Override Protected Zero at POS () {// Todo Auto Generate Method Stub sm.unregisterListener (this); Super.onPause (); } @ Override Public Watch On Sensor Change (Sense Everte E) {// Todo Auto-Generated Method Stub {thread.sleep (16); } Grip (Interrupted E1) {// TODO Auto-Generated Cache Block e1.printStackTrace (); } Alpha = (float) 0.8; Sensor X = Alpha * Sensor X + (1-alpha) * E.View [0]; Sensor Y = Alpha * Sensor Y + (1-alpha) * E.View [1]; // sensor X = E.View [0]; // sensor Y = e.values ​​[1]; } @ Override public blank on actress change (sensor sensor, int accuracy) {// Todo auto-generated method stub}  

}

I think that you are computing and checking that the ball comes to the edge of the canvas or not. You only need to use your activity.

Intent Intent = New Intent (Disability, yournewactivityclass.class); StartActivity;

Or if you have your own reference

  intent to intent = new intent ((activity) reference, yournewactivityclass.class); StartActivity;  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -