Canvas mit dem Accelorometersensor bewegen

Hallo Leute
Ich versuche momentan ein mit canvas gezeichnetes objekt mit dem accelorometersensor zu bewegen.
Das mit dem Sensor hab ich schon ich muss es nur noch hinkriegen das dan das objekt bewegt wird.
Habt ihr eine Idee wie ich das am besten umsetzen kann ?

Falls jemand den Code vom Sensor braucht:
Java:
if(event.values.length > 0) {
	          float light = event.values[0];
   	          wert = light;
	          y = Float.toString(light);
	          if (wert > 1) {
	 	         if (wert >= 1 && wert <= 3) {
		            textView1.setText("links1");
		            wert1 = "links1";
		            
		         }
		         if (wert >= 3 && wert <= 6) {
		            textView1.setText("links2");
		            wert1 = "links2";
		            
		         }
		         if (wert > 6) {
		            textView1.setText("links3");
		            wert1 = "links3";
		          
		         }
	          }
	    
	          if (wert < -1) {
		         if (wert >= -3 && wert <= -1) {
		            textView1.setText("rechts1");
		            wert1 = "rechts1";
		            
		         }
		         if (wert >= -6 && wert <= -3) {
		            textView1.setText("rechts2");
		            wert1 = "rechts2";
		           
		         }
		         if (wert < -6) {
		            textView1.setText("rechts3");
		            wert1 = "rechts3";
		         
		         }
	          }
	    
	          if (wert >= -1 && wert <= 1) {
		         textView1.setText("mitte");
		         wert1 = "mitte";
		       
	          }
	       }
	    }
	 };
     sensor = manager.getDefaultSensor(Sensor.TYPE_GRAVITY);
	 if(sensor != null) {
	    manager.registerListener(listener, sensor, SensorManager.SENSOR_MAGNETIC_FIELD);
	 }
	 else {
	    textView1.setText("Kein Sensor gefunden");
	 }
 
Zuletzt bearbeitet:
Ähnliche Java Themen
  Titel Forum Antworten Datum
Arif Android Canvas wird nicht gezeichnet? Android & Cross-Platform Mobile Apps 0
Dechasa Android Android - Canvas NullpointException Android & Cross-Platform Mobile Apps 2
Z Canvas onDraw() Variablen muss in der Methode initialisiert werden Android & Cross-Platform Mobile Apps 1
F Mit Canvas zeichen und durch einen Timer aktualiesieren Android & Cross-Platform Mobile Apps 1
E Android Zeichnen auf Canvas - Teilbereich als Bild speichern Android & Cross-Platform Mobile Apps 3
B onDraw Canvas jede Millisekunde aufrufen? Android & Cross-Platform Mobile Apps 12
G canvas in view anzeigen Android & Cross-Platform Mobile Apps 10
S Android Canvas - drawText - Update Text in ActionListener Android & Cross-Platform Mobile Apps 8
B Java ME Canvas Android & Cross-Platform Mobile Apps 2
J Java ME Canvas Klasse Gameloop und Funktion Android & Cross-Platform Mobile Apps 2
B Java ME Leere Canvas Seite Android & Cross-Platform Mobile Apps 21
P Java ME Texteingabe Canvas Android & Cross-Platform Mobile Apps 2
D wie geht Klassenvererbung von Canvas Klassen Android & Cross-Platform Mobile Apps 2
U Probleme mit der drawString Methode bei Canvas Android & Cross-Platform Mobile Apps 8
H Canvas kann nichts auf Graphics drawen Android & Cross-Platform Mobile Apps 3
M Textfeld in Canvas, implementation der keys aendern Android & Cross-Platform Mobile Apps 8
M Text in Canvas scrollen lassen Android & Cross-Platform Mobile Apps 13
M Wie in einer anderen "nicht canvas" klasse zeichne Android & Cross-Platform Mobile Apps 5
U ein texteingabefeld auf einem Canvas . Android & Cross-Platform Mobile Apps 2
A Problem: Canvas-Grösse Motorola RAZR v3r Android & Cross-Platform Mobile Apps 8
F Canvas Stringlänge Android & Cross-Platform Mobile Apps 2
J Einen String bewegen wie? Android & Cross-Platform Mobile Apps 3

Ähnliche Java Themen

Neue Themen


Oben