質問編集履歴

1

書式の改善

2018/07/08 08:45

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -24,8 +24,6 @@
24
24
 
25
25
 
26
26
 
27
- // Use this for initialization
28
-
29
27
  void Start () {
30
28
 
31
29
  rb2d = GetComponent<Rigidbody2D>();
@@ -34,31 +32,27 @@
34
32
 
35
33
 
36
34
 
37
- // Update is called once per frame
38
-
39
35
  void Update () {
40
36
 
41
37
  if (Input.touchCount > 0) {
42
38
 
43
39
  Touch touch = Input.GetTouch(0);
44
40
 
45
- //画面右半分をタッチしていたら
41
+ //画面右半分をタッチしていたら右に移動
46
42
 
47
43
  if(touch.position.x > Screen.width * 0.5f) {
48
44
 
49
45
  direction = 1f;
50
46
 
51
- //画面左半分をタッチしていたら
47
+ //画面左半分をタッチしていたら左に移動
52
48
 
53
- }else if (touch.position.x < Screen.width * 0.5f) {
49
+ } else if (touch.position.x < Screen.width * 0.5f) {
54
50
 
55
51
  direction = -1f;
56
52
 
57
- }
53
+ } else {
58
54
 
59
- else {
60
-
61
- direction = 0f;
55
+ direction = 0f; //←何もタッチしていない場合は反応なし
62
56
 
63
57
  }
64
58