09.02.2017 Views

creez-des-applications-pour-android

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6.7 TP : un labyrinthe<br />

import <strong>android</strong>.content.DialogInterface;<br />

import <strong>android</strong>.os.Bundle;<br />

public class LabyrintheActivity extends Activity {<br />

// Identifiant de la boîte de dialogue de victoire<br />

public static final int VICTORY_DIALOG = 0 ;<br />

// Identifiant de la boîte de dialogue de défaite<br />

public static final int DEFEAT_DIALOG = 1 ;<br />

// Le moteur graphique du jeu<br />

private LabyrintheView mView = null ;<br />

// Le moteur physique du jeu<br />

private LabyrintheEngine mEngine = null ;<br />

@Override<br />

public void onCreate(Bundle savedInstanceState) {<br />

super.onCreate(savedInstanceState);<br />

mView = new LabyrintheView(this);<br />

setContentView(mView);<br />

mEngine = new LabyrintheEngine(this);<br />

Boule b = new Boule();<br />

mView.setBoule(b);<br />

mEngine.setBoule(b);<br />

}<br />

List mList = mEngine.buildLabyrinthe();<br />

mView.setBlocks(mList);<br />

@Override<br />

protected void onResume() {<br />

super.onResume();<br />

mEngine.resume();<br />

}<br />

@Override<br />

protected void onPause() {<br />

super.onStop();<br />

mEngine.stop();<br />

}<br />

@Override<br />

public Dialog onCreateDialog (int id) {<br />

AlertDialog.Builder builder = new AlertDialog.Builder(this);<br />

switch(id) {<br />

case VICTORY_DIALOG:<br />

465

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!