teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

//override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?){を変更した。

2018/08/07 10:21

投稿

fugu
fugu

スコア35

title CHANGED
File without changes
body CHANGED
@@ -33,7 +33,8 @@
33
33
  }
34
34
 
35
35
 
36
+
36
- override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?){
37
+ override func touchesMoved(_ touches: Set<UITouch>, with: UIEvent?){
37
38
  let location = touches.first!.location(in: self)
38
39
  self.position = location
39
40
  //この行を追加して座標を確認しました。

1

座標のズレを確認しました。

2018/08/07 10:21

投稿

fugu
fugu

スコア35

title CHANGED
File without changes
body CHANGED
@@ -36,10 +36,28 @@
36
36
  override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?){
37
37
  let location = touches.first!.location(in: self)
38
38
  self.position = location
39
+ //この行を追加して座標を確認しました。
40
+ print("Square",self.position,"location",location)
41
+
39
42
  }
40
43
 
41
44
  required init?(coder aDecoder: NSCoder) {
42
45
  fatalError("init(coder:) has not been implemented")
43
46
  }
44
47
  }
48
+ ```
49
+ 座標のログの最初の数行です
50
+ 四角ノードのポジションをx:100, y:100に設定しているので
51
+ ズレているようです。
52
+ ```log
53
+ Square (-2.33332824707031, 6.3333740234375) location (-2.33332824707031, 6.3333740234375)
54
+ Square (100.333320617676, 100.666618347168) location (100.333320617676, 100.666618347168)
55
+ Square (-1.66666412353516, 7.66672515869141) location (-1.66666412353516, 7.66672515869141)
56
+ Square (100.999992370605, 101.333267211914) location (100.999992370605, 101.333267211914)
57
+ Square (-0.333320617675781, 10.0001068115234) location (-0.333320617675781, 10.0001068115234)
58
+ Square (101.666641235352, 102.33325958252) location (101.666641235352, 102.33325958252)
59
+ Square (1.66670227050781, 13.3334121704102) location (1.66670227050781, 13.3334121704102)
60
+ Square (102.666625976562, 103.999969482422) location (102.666625976562, 103.999969482422)
61
+ Square (2.00003814697266, 14.0000152587891) location (2.00003814697266, 14.0000152587891)
62
+ Square (103.666618347168, 105.666679382324) location (103.666618347168, 105.666679382324)
45
63
  ```