回答編集履歴

1

誤りがあったので修正\.

2015/12/17 18:33

投稿

norton
norton

スコア11

test CHANGED
@@ -230,32 +230,32 @@
230
230
 
231
231
  //スクリーンは左上原点だが、OpenGLESフレームバッファの原点を左下と想定するのでY軸を反転させる.
232
232
 
233
+ // touch.x = (touch.x / screenWidth) * BASE_FRUSTUM_WIDTH * zoom;
234
+
235
+ // touch.y = (1 - touch.y / screenHeight) * BASE_FRUSTUM_HEIGHT * zoom;
236
+
237
+ // //ズームが適用されたワールド座標上での適切なタッチ座標に変換する.
238
+
239
+ // touch.add(position).sub(BASE_FRUSTUM_WIDTH * zoom / 2, BASE_FRUSTUM_HEIGHT * zoom / 2);
240
+
241
+ //delete <<<
242
+
243
+ //add >>>
244
+
245
+ float diffWidthViewportAndFrustum = (screenWidth - viewportWidth) / 2;
246
+
247
+ float diffHeightViewportAndFrustum = (screenHeight - viewportHeight) / 2;
248
+
249
+
250
+
233
- touch.x = (touch.x / screenWidth) * BASE_FRUSTUM_WIDTH * zoom;
251
+ touch.x = (touch.x / viewportWidth) * BASE_FRUSTUM_WIDTH * zoom;
234
-
252
+
235
- touch.y = (1 - touch.y / screenHeight) * BASE_FRUSTUM_HEIGHT * zoom;
253
+ touch.y = (1 - touch.y / viewportHeight) * BASE_FRUSTUM_HEIGHT * zoom;
236
254
 
237
255
  //ズームが適用されたワールド座標上での適切なタッチ座標に変換する.
238
256
 
239
257
  touch.add(position).sub(BASE_FRUSTUM_WIDTH * zoom / 2, BASE_FRUSTUM_HEIGHT * zoom / 2);
240
258
 
241
- //delete <<<
242
-
243
- //add >>>
244
-
245
- float diffWidthViewportAndFrustum = (screenWidth - viewportWidth) / 2;
246
-
247
- float diffHeightViewportAndFrustum = (screenHeight - viewportHeight) / 2;
248
-
249
-
250
-
251
- touch.x = (touch.x / viewportWidth) * BASE_FRUSTUM_WIDTH * zoom;
252
-
253
- touch.y = (1 - touch.y / viewportHeight) * BASE_FRUSTUM_HEIGHT * zoom;
254
-
255
- //ズームが適用されたワールド座標上での適切なタッチ座標に変換する.
256
-
257
- touch.add(position).sub(BASE_FRUSTUM_WIDTH * zoom / 2, BASE_FRUSTUM_HEIGHT * zoom / 2);
258
-
259
259
  touch.add(-(diffWidthViewportAndFrustum / magnification * zoom), (diffHeightViewportAndFrustum / magnification * zoom));
260
260
 
261
261
  //add <<<