{"id":14956,"date":"2022-05-12T22:05:32","date_gmt":"2022-05-12T14:05:32","guid":{"rendered":"https:\/\/www.bookcard.net\/wordpress\/?p=14956"},"modified":"2022-05-29T17:47:35","modified_gmt":"2022-05-29T09:47:35","slug":"android_touch_zoom","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/android_touch_zoom\/","title":{"rendered":"Android\u4e24\u6307\u7e2e\u653e"},"content":{"rendered":"<figure id=\"attachment_14957\" aria-describedby=\"caption-attachment-14957\" style=\"width: 1280px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2022\/05\/android_touch_zoom.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14957\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2022\/05\/android_touch_zoom.jpg\" alt=\"Android\u4e24\u6307\u7e2e\u653e\" width=\"1280\" height=\"800\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2022\/05\/android_touch_zoom.jpg 1280w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2022\/05\/android_touch_zoom-300x188.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2022\/05\/android_touch_zoom-768x480.jpg 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/a><figcaption id=\"caption-attachment-14957\" class=\"wp-caption-text\">Android\u4e24\u6307\u7e2e\u653e<\/figcaption><\/figure>\n<p>\u4e4b\u524d\u505aAndroid \u6e38\u6232\u7686\u5355\u3e03\u89e6\u6478, \u8ad7\u4f4f\u4fc2\u98a8\u6c34\u7f85\u76e4\u5be6\u73fe\u4e24\u6307\u7e2e\u653e.<\/p>\n<p>\u89e6\u6478\u5206\u53c1\u52d5\u4f5c\u300e\u9b06\u300f\u300e\u64b3\u300f\u300e\u62d6\u300f.<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"288\">\u52d5\u4f5c<\/td>\n<td width=\"288\">\u6ce8\u91ca<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">#define TOUCH_UP\u00a0\u00a0\u00a0\u00a0\u00a0 1<\/td>\n<td width=\"288\">\u9b06<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">#define TOUCH_DOWN\u00a0\u00a0\u00a0 2<\/td>\n<td width=\"288\">\u64b3<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">#define TOUCH_DRAGGED 3<\/td>\n<td width=\"288\">\u62d6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u96d9\u624b\u62fe\u6307, \u9664\u975e\u7528\u57cb\u811a\u6307<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"288\">#define MAX_FINGER\u00a0\u00a0\u00a0 10<\/td>\n<td width=\"288\">\u62fe\u6307<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5b9a\u7fa9TOUCH\u7d50\u6784, \u7528\u849e\u5b58\u62fe\u6307\u300e\u65b9\u4f4d\u300f\u540c\u300e\u52d5\u4f5c\u300f<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"288\">TOUCH\u7d50\u6784<\/td>\n<td width=\"288\">\u6ce8\u91ca<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">typedef struct TOUCH_STR{<\/td>\n<td width=\"288\"><\/td>\n<\/tr>\n<tr>\n<td width=\"288\">\u00a0\u00a0\u00a0 int count;<\/td>\n<td width=\"288\">\u624b\u6307\u91cf, \u6700\u591a10\u6307<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">\u00a0\u00a0\u00a0 int action[MAX_FINGER];<\/td>\n<td width=\"288\">\u52d5\u4f5c<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">\u00a0\u00a0\u00a0 int x[MAX_FINGER];<\/td>\n<td width=\"288\">X\u5ea7\u6a19<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">\u00a0\u00a0\u00a0 int y[MAX_FINGER];<\/td>\n<td width=\"288\">Y\u5ea7\u6a19<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">}TOUCH,*TOUCH_PTR;<\/td>\n<td width=\"288\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7528\u6808stack\u849e\u5b58\u89e6\u6478,<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"288\">#define MAX_TOUCH\u00a0\u00a0\u00a0\u00a0 32<\/td>\n<td width=\"288\">\u68e7\u9ad832<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">TOUCH touch_array[MAX_TOUCH] ;<\/td>\n<td width=\"288\">\u89e6\u6478\u68e7<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">int\u00a0\u00a0 touch_count;<\/td>\n<td width=\"288\">\u68e7\u9802<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u68e7\u9802\u52a0\u58f9, \u6bcf\u6b21\u5b58\u89e6\u6478\u300e\u65b9\u4f4d\u300f\u540c\u300e\u52d5\u4f5c\u300f\u524d\u8abf\u7528<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">int Add_Touch(){<\/p>\n<p>TOUCH_PTR touch;<\/p>\n<p>int index;<\/p>\n<p>if(touch_count &gt;= MAX_TOUCH)<\/p>\n<p>return touch_count;<\/p>\n<p>index = touch_count;<\/p>\n<p>++touch_count;\/\/ \u68e7\u9802\u52a0\u58f9<\/p>\n<p>touch = &amp;touch_array[index];<\/p>\n<p>touch-&gt;count = 0;<\/p>\n<p>return touch_count;<\/p>\n<p>}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u68e7\u9802\u51cf\u58f9, \u8b80\u300e\u65b9\u4f4d\u300f\u540c\u300e\u52d5\u4f5c\u300f\u5f8c\u8abf\u7528<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">int Sub_Touch(){<\/p>\n<p>if(touch_count &lt;= 0)<\/p>\n<p>return touch_count;<\/p>\n<p>&#8211;touch_count;<\/p>\n<p>return touch_count;<\/p>\n<p>}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5b58\u89e6\u6478\u300e\u65b9\u4f4d\u300f\u540c\u300e\u52d5\u4f5c\u300f, finger\u4fc2\u624b\u6307\u7d22\u5f15<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">bool Set_Touch(int finger,int action,float x,float y){<\/p>\n<p>int index;<\/p>\n<p>TOUCH_PTR touch;<\/p>\n<p>index = touch_count-1; \/\/ \u68e7\u9802<\/p>\n<p>touch = &amp;touch_array[index];<\/p>\n<p>if(touch-&gt;count &lt; finger + 1)<\/p>\n<p>touch-&gt;count = finger + 1;<\/p>\n<p>touch-&gt;action[finger] = action;<\/p>\n<p>touch-&gt;x[finger] = x ;<\/p>\n<p>touch-&gt;y[finger] = y ;<\/p>\n<p>return true;<\/p>\n<p>}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8b80\u89e6\u6478, \u300e\u65b9\u4f4d\u300f\u540c\u300e\u52d5\u4f5c\u300f, finger\u4fc2\u624b\u6307\u7d22\u5f15<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">bool Get_Touch(int finger,int * action,int * x,int * y){<\/p>\n<p>TOUCH_PTR\u00a0 touch;<\/p>\n<p>int index;<\/p>\n<p>if(touch_count == 0)<\/p>\n<p>return false;<\/p>\n<p>index = touch_count &#8211; 1;<\/p>\n<p>touch = &amp;touch_array[index];<\/p>\n<p>*action = touch-&gt;action[finger];<\/p>\n<p>*x = touch-&gt;x[finger];<\/p>\n<p>*y = touch-&gt;y[finger];<\/p>\n<p>return true;<\/p>\n<p>}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8a08\u4e24\u6307(x0,y0)(x1,y1)\u7e2e\u653e\u6642\u4e2d\u5fc3\u4f4d(cx,cy)<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"288\">float cx = (x0 &#8211; x1)\/2 + x1;<\/td>\n<td width=\"288\"><\/td>\n<\/tr>\n<tr>\n<td width=\"288\">float cy = (y0 &#8211; y1)\/2 + y1;<\/td>\n<td width=\"288\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>2D\u89e6\u6478\u5750\u6807\u8f6c\u5c4f\u5e55\u5750\u6807<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"288\">VECTOR2D touchPoint2D;<\/td>\n<td width=\"288\">2D\u89e6\u6478\u9ede(x,y)<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">VECTOR3D touchPoint3D;<\/td>\n<td width=\"288\">3D\u89e6\u6478\u9ede(x,y,z)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u89e6\u6478\u5750\u6807\u8f6c3D\u4e16\u754c\u5750\u6807<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">Init_VECTOR2D(&amp;touchPoint2D, cx, cy);<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">TouchToWorld(camera3D, &amp;touchPoint2D, &amp;touchPoint3D);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8a08\u4e24\u6307\u8ddd,<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">Init_VECTOR2D(&amp;v0,x0,y0);<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">Init_VECTOR2D(&amp;v1,x1,y1);<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">Sub_VECTOR2D(&amp;vdiff,&amp;v0,&amp;v1);<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">length = Length_VECTOR2D(&amp;vdiff);<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6307\u8ddd\u62c9\u958b\u653e\u5927, \u4e24\u6307\u884c\u57cb\u7e2e\u7d30. \u901a\u904e\u79fb3D\u76f8\u6a5f\u5be6\u73fe\u7e2e\u653e.<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"397\">if(_length &gt; length ) y = Camera3D.pos.y + 2;<\/td>\n<td width=\"179\">\u7e2e\u7d30<\/td>\n<\/tr>\n<tr>\n<td width=\"397\">if(_length &lt; length ) y = Camera3D.pos.y &#8211; 2;<\/td>\n<td width=\"179\">\u653e\u5927<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e4b\u524d\u505aAndroid \u6e38\u6232\u7686\u5355\u3e03\u89e6\u6478, \u8ad7\u4f4f\u4fc2\u98a8\u6c34\u7f85\u76e4\u5be6\u73fe\u4e24\u6307\u7e2e\u653e. \u89e6\u6478\u5206\u53c1\u52d5\u4f5c\u300e\u9b06\u300f\u300e\u64b3\u300f\u300e\u62d6\u300f. \u52d5\u4f5c  &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/android_touch_zoom\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">Android\u4e24\u6307\u7e2e\u653e<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,11,223],"tags":[2,10,222],"class_list":["post-14956","post","type-post","status-publish","format-standard","hentry","category-android","category-algorithm","category-geomantic_compass","tag-android","tag-algorithm","tag-geomantic_compass","entry"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/14956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/comments?post=14956"}],"version-history":[{"count":3,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/14956\/revisions"}],"predecessor-version":[{"id":14996,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/14956\/revisions\/14996"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=14956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=14956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=14956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}