Blame view

app/src/main/java/tonio/noa/TutorialScene5Activity.java 2.47 KB
aaefb55f   aarnaude   scène 4 : débogguée
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  package tonio.noa;
  
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.MotionEvent;
  import android.view.View;
  
  /**
   * Created by psyk on 24/01/18.
   */
  
  public class TutorialScene5Activity extends MyPlayActivity implements View.OnTouchListener {
  
      private int win_counter = 0;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          Intent i = new Intent(this, ConsigneActivity.class);
          i.putExtra("keyConsigne", "Cette fois\ntu dois cliquer sur les carrés verts!\nC'est ta dernière mission ;)");
          int requestCode = 0;
          startActivityForResult(i, requestCode);
  
      }
  
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
  
          setContentView(R.layout.tutorial5_display);
  
          findViewById(R.id.blue_rectangle51).setOnTouchListener(this);
          findViewById(R.id.blue_rectangle52).setOnTouchListener(this);
          findViewById(R.id.blue_rectangle53).setOnTouchListener(this);
          findViewById(R.id.blue_rectangle54).setOnTouchListener(this);
          findViewById(R.id.red_rectangle51).setOnTouchListener(this);
          findViewById(R.id.red_rectangle52).setOnTouchListener(this);
          findViewById(R.id.red_rectangle53).setOnTouchListener(this);
          findViewById(R.id.red_rectangle54).setOnTouchListener(this);
          findViewById(R.id.green_rectangle51).setOnTouchListener(this);
          findViewById(R.id.green_rectangle52).setOnTouchListener(this);
          findViewById(R.id.green_rectangle53).setOnTouchListener(this);
          findViewById(R.id.green_rectangle54).setOnTouchListener(this);
  
      }
  
      @Override
      public boolean onTouch(View view, MotionEvent event) {
          if (event.getAction() == MotionEvent.ACTION_DOWN) {
              if (view == findViewById(R.id.green_rectangle51)
                      || view == findViewById(R.id.green_rectangle52)
                      || view == findViewById(R.id.green_rectangle53)
                      || view == findViewById(R.id.green_rectangle54)) {
                  view.setVisibility(View.INVISIBLE);
                  win_counter++;
              } else view.setBackgroundColor(0xff888888);
              return true;
          }
          if (win_counter == 4) {
              this.bravoPage(null);
              return true;
          } else
              return false;
      }
  
      @Override
      protected void next() {
          this.backHome(null);
      }
  }