Hallo an alle im Java-Forum,
ich habe folgendes Problem:
Ich habe eine Klasse "GameView" geschrieben, die die Klasse SurfaceView erweitert. Bei der Erzeugung eines GameView-Objektes mit "private GameView gameView = new GameView(this);" wird ja mit "this" der gesamte Context der App und damit die ganze Oberfläche in die GameView einbezogen ( so viel ich weiß ).
Im Konstruktor dieser Klasse wird mit "SurfaceHolder myHolder = getHolder();" auf Basis der GameView ( erweiterte SurfaceView) ein SurfaceHolder erzeugt, mit dem ich die Spielfigur laufen lassen kann. So weit funktioniert das auch. Jedoch läuft die Figur nur los wenn man irgendwo auf den Bildschirm tippt.
Jetzt möchte ich aber ein ein Button ( als Anfang für ein Steuerkreuz ) einbeziehen und will damit erreichen dass die Spielfigur nur losläuft, wenn man diesen Button betätigt.
Was noch zu erwähnen ist: In der onCreate()-Methode steht bei mir "setContentView(gameView)"
Wie kann ich über die SurfaceView einen Button legen? Oder gibt es eine andere Möglichkeit dies zu realisieren?
Ich hoffe dass mir diesbezüglich jemand weiterhelfen kann.
Viele Grüße
euer Akechi Kogoro
ich habe folgendes Problem:
Ich habe eine Klasse "GameView" geschrieben, die die Klasse SurfaceView erweitert. Bei der Erzeugung eines GameView-Objektes mit "private GameView gameView = new GameView(this);" wird ja mit "this" der gesamte Context der App und damit die ganze Oberfläche in die GameView einbezogen ( so viel ich weiß ).
Im Konstruktor dieser Klasse wird mit "SurfaceHolder myHolder = getHolder();" auf Basis der GameView ( erweiterte SurfaceView) ein SurfaceHolder erzeugt, mit dem ich die Spielfigur laufen lassen kann. So weit funktioniert das auch. Jedoch läuft die Figur nur los wenn man irgendwo auf den Bildschirm tippt.
Jetzt möchte ich aber ein ein Button ( als Anfang für ein Steuerkreuz ) einbeziehen und will damit erreichen dass die Spielfigur nur losläuft, wenn man diesen Button betätigt.
Was noch zu erwähnen ist: In der onCreate()-Methode steht bei mir "setContentView(gameView)"
Wie kann ich über die SurfaceView einen Button legen? Oder gibt es eine andere Möglichkeit dies zu realisieren?
Ich hoffe dass mir diesbezüglich jemand weiterhelfen kann.
Viele Grüße
euer Akechi Kogoro