{"id":81,"date":"2016-09-19T13:57:26","date_gmt":"2016-09-19T05:57:26","guid":{"rendered":"http:\/\/blog.xrhoujie.com\/?p=81"},"modified":"2021-10-19T10:39:19","modified_gmt":"2021-10-19T02:39:19","slug":"%e7%99%bd%e9%b9%ad%e5%bc%80%e5%8f%91-%e6%94%be%e5%a4%a7%e9%95%9c%e6%95%88%e6%9e%9c","status":"publish","type":"post","link":"http:\/\/blog.xrhoujie.com\/?p=81","title":{"rendered":"\u767d\u9e6d\u5f00\u53d1-\u653e\u5927\u955c\u6548\u679c"},"content":{"rendered":"<div class=\"blog-abstract\">\u6458\u8981: \u6536\u5230\u6211\u5e08\u7236\u7684\u542f\u53d1\uff0c\u505a\u4e86\u4e00\u4e2a\u653e\u5927\u955c\u7279\u6548\uff0c\u5c0f\u7684\u77e5\u8bc6\u901a\u8fc7\u4e0d\u65ad\u79ef\u7d2f\u5c31\u53d8\u6210\u4e86\u5927\u7a0b\u5e8f\u3002<\/div>\n<div id=\"blogBody\" class=\"blog-body\">\n<div class=\"BlogContent\">\n<p>\u5404\u4f4d\u8001\u54e5\u5750\u7a33\u4e86\uff0c\u5c0f\u5f1f\u6211\u5f00\u59cb\u53d1\u8f66\u4e86\uff01\uff01<\/p>\n<p>\u5e9f\u8bdd\u5c11\u8bf4\uff0c\u76f4\u63a5\u770b\u6548\u679c\u5c82\u4e0d\u662f\u7f8e\u6ecb\u6ecb\uff0c<\/p>\n<p><img loading=\"lazy\" src=\"https:\/\/static.oschina.net\/uploads\/space\/2016\/1202\/123356_xxVN_2760473.jpg\" alt=\"\" width=\"685\" height=\"478\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" src=\"https:\/\/static.oschina.net\/uploads\/space\/2016\/1202\/123429_WZTU_2760473.jpg\" alt=\"\" width=\"545\" height=\"478\" \/><\/p>\n<p>\u3002\u3002\u3002\u3002\u8001\u54e5\u4eec\u53ef\u80fd\u4e0d\u4f1a\u73a9\uff0c\u4e0b\u9762\u7531\u6211\u8fd9\u4e2a\u8001\u53f8\u673a\u6765\u544a\u8bc9\u5927\u5bb6\u5982\u4f55\u73a9\uff0c\u54c8\u54c8\u54c8 \uff0c\u9996\u5148\u8fd9\u4e2ademo\u56fe\u7247\u7edd\u5bf9\u4e0d\u662f\u4e00\u5f20\uff0c\u662f\u4e24\u5f20\uff0c\u4e00\u4e2a\u5927\u56fe\uff0c\u4e00\u4e2a\u5c0f\u56fe\uff0c\u8bf7\u770b\u8fd9\u91cc<\/p>\n<p><img loading=\"lazy\" src=\"https:\/\/static.oschina.net\/uploads\/space\/2016\/1202\/140746_yb2z_2760473.jpg\" alt=\"\" width=\"377\" height=\"250\" \/><\/p>\n<p>\u6211\u4eec\u5148\u51c6\u5907\u597d\u4e09\u4e2a\u7d20\u6750\uff0c<\/p>\n<p>\u653e\u5230\u8fd9\u91cc<\/p>\n<p><img loading=\"lazy\" src=\"https:\/\/static.oschina.net\/uploads\/space\/2016\/1202\/140938_NypH_2760473.jpg\" alt=\"\" width=\"782\" height=\"582\" \/><\/p>\n<p>\u5c06\u7d20\u6750\u653e\u7f6e\u5728resource\u4e0b\u9762\u7684assets\u91cc\u9762\uff0c\u653e\u8fdb\u53bb\u540e\u914d\u7f6e\u6587\u4ef6\u8868\u4f1a\u628a\u56fe\u7247\u81ea\u52a8\u8f6c\u5316\u4e3ajson\u6570\u636e\u7684\u65b9\u5f0f\u8fdb\u884c\u5b58\u50a8\uff0c\u8fd9\u6837\u4e00\u6765\u8001\u54e5\u4eec\u7684\u56fe\u7247\u4f53\u79ef\u5f97\u5230\u538b\u7f29\uff0c\u7a0b\u5e8f\u8dd1\u7684\u66f4666 \uff0c\u7f8e\u6ecb\u6ecb\u554a \uff0c<\/p>\n<p>src\u662f\u6211\u4eec\u7528\u6765\u653e\u7f6e\u7684\u4ee3\u7801\u7684\u6587\u4ef6\u5939,\u8fd9\u91cc\u6211\u5148\u7b80\u5355\u516c\u5f00\u4e00\u90e8\u5206\u4ee3\u7801\u8fdb\u884c\u8bf4\u660e\u54c8\uff0c<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"hljs kotlin\"><code class=\"language-javascript hljs\">\t\t<span class=\"hljs-keyword\">var<\/span> smallBmp = <span class=\"hljs-keyword\">new<\/span> egret.Bitmap(RES.getRes(<span class=\"hljs-string\">\"small_jpg\"<\/span>));\r\n\t\t<span class=\"hljs-keyword\">this<\/span>.addChild(smallBmp);\r\n\r\n\t\t<span class=\"hljs-comment\">\/\/\u6dfb\u52a0\u5927\u56fe<\/span>\r\n\t\t<span class=\"hljs-keyword\">this<\/span>._bigBmp = <span class=\"hljs-keyword\">new<\/span> egret.Bitmap(RES.getRes(<span class=\"hljs-string\">\"big_jpg\"<\/span>));\r\n\t\t<span class=\"hljs-keyword\">this<\/span>.addChild(<span class=\"hljs-keyword\">this<\/span>._bigBmp);<\/code><\/pre>\n<p>\u521b\u5efa\u6dfb\u52a0\u56fe\u7247\u5230\u753b\u5e03\u4e0a\uff0c<\/p>\n<pre class=\"hljs kotlin\"><code class=\"language-javascript hljs\"><span class=\"hljs-comment\">\/\/\u8ba1\u7b97\u5927\u5c0f\u56fe\u7684\u5bbd\u5ea6\u6bd4<\/span>\r\n\t\t<span class=\"hljs-keyword\">this<\/span>.scaleWH = <span class=\"hljs-keyword\">this<\/span>._bigBmp.width \/ smallBmp.width;\r\n\r\n\t\t<span class=\"hljs-comment\">\/\/\u6dfb\u52a0\u653e\u5927\u955c\u5bb9\u5668\u7528\u6765\u79fb\u52a8<\/span>\r\n\t\t<span class=\"hljs-keyword\">this<\/span>._container = <span class=\"hljs-keyword\">new<\/span> egret.Sprite();\r\n\t\t<span class=\"hljs-keyword\">this<\/span>.addChild(<span class=\"hljs-keyword\">this<\/span>._container)\r\n\t\t<span class=\"hljs-keyword\">this<\/span>._container.x = <span class=\"hljs-keyword\">this<\/span>._container.y = <span class=\"hljs-number\">300<\/span>;<\/code><\/pre>\n<p>\u6bd4\u503c\u53d6\u51fa\u56fe\u7247\u7684\u7f29\u653e\u6eb6\u5ea6\u5dee\uff0c\u4e4b\u540e\u6211\u4eec\u9876\u4e00\u4e2a\u6a21\u5757(\u53ef\u4ee5\u7406\u89e3\u4e3acontainer)\u5728\u8fd9\u91cc\u9762\u6211\u4eec\u8fdb\u884c\u8bbe\u7f6e\u5bbd\u9ad8<\/p>\n<pre class=\"hljs kotlin\"><code class=\"language-javascript hljs\">\t\t<span class=\"hljs-comment\">\/\/\u5706\u5f62\u906e\u7f69\u56fe\u5f62<\/span>\r\n\t\t<span class=\"hljs-keyword\">var<\/span> circleShape = <span class=\"hljs-keyword\">new<\/span> egret.Shape();\r\n\t\tcircleShape.graphics.beginFill(<span class=\"hljs-number\">0x000000<\/span>);\r\n\t\tcircleShape.graphics.drawCircle(<span class=\"hljs-number\">0<\/span>,<span class=\"hljs-number\">0<\/span>,<span class=\"hljs-number\">70<\/span>);\r\n\t\tcircleShape.graphics.endFill();\r\n\t\t<span class=\"hljs-keyword\">this<\/span>._container.addChild(circleShape);\r\n\t\t<span class=\"hljs-keyword\">this<\/span>._bigBmp.mask = circleShape;<\/code><\/pre>\n<p>\u5b9a\u4e49\u6a21\u578b\uff0c\u586b\u5145\u989c\u8272\uff0c\u753b\u5706\uff0c\u7ed3\u675f\u586b\u5145\u66f4\u65b0\u5230\u753b\u5e03\u4e0a\uff0c\u8bbe\u7f6e\u906e\u7f69<\/p>\n<pre class=\"hljs actionscript\"><code class=\"language-javascript hljs\">\t\t<span class=\"hljs-comment\">\/\/\u653e\u5927\u955c\u8fb9\u6846<\/span>\r\n\t\t<span class=\"hljs-keyword\">var<\/span> glassBmp = <span class=\"hljs-keyword\">new<\/span> egret.Bitmap(RES.getRes(<span class=\"hljs-string\">\"glass_png\"<\/span>));\r\n\t\t<span class=\"hljs-keyword\">this<\/span>._container.addChild(glassBmp);\r\n\t\tglassBmp.x = <span class=\"hljs-number\">-70<\/span>;\r\n\t\tglassBmp.y = <span class=\"hljs-number\">-70<\/span>;<\/code><\/pre>\n<p>\u8001\u54e5\u4eec\u53ef\u80fd\u4f1a\u95ee\u4e3a\u5565\u662f-70 \u56e0\u4e3a\u5750\u6807\u5706\u70b9\u662f0.0\u5373\u5de6\u4e0a\u89d2\u7684\u4f4d\u7f6e\u4e0a-70 -70\u662f\u4e3a\u4e86\u8ba9\u4ed6\u5728&#8221;\u6b63\u4e2d\u95f4\u4f4d\u7f6e&#8221;<\/p>\n<pre class=\"hljs kotlin\"><code class=\"language-javascript hljs\"><span class=\"hljs-keyword\">this<\/span>.addEventListener(egret.TouchEvent.TOUCH_BEGIN,<span class=\"hljs-keyword\">this<\/span>.touch_begin,<span class=\"hljs-keyword\">this<\/span>);\r\n\t\t<span class=\"hljs-keyword\">this<\/span>.addEventListener(egret.TouchEvent.TOUCH_MOVE,<span class=\"hljs-keyword\">this<\/span>.touch_move,<span class=\"hljs-keyword\">this<\/span>);\r\n\t\t<span class=\"hljs-keyword\">this<\/span>.addEventListener(egret.TouchEvent.TOUCH_END,<span class=\"hljs-keyword\">this<\/span>.touch_end,<span class=\"hljs-keyword\">this<\/span>);<\/code><\/pre>\n<p>\u8fd9\u91cc\u6dfb\u52a0\u4e09\u4e2a\u76d1\u542c\u4e8b\u4ef6\u3002 \u7b2c\u4e00\u4e2a\u662f\u5f53\u7528\u6237\u8fdb\u884c\u89e6\u6478\u65f6\u5019\u6267\u884c\u51fd\u6570touch_begin\uff0c<\/p>\n<p>\u7b2c\u4e8c\u4e2a\u662f\u7528\u6237\u89e6\u6478\u79fb\u52a8\u6267\u884c\u51fd\u6570 touch_move<\/p>\n<p>\u7b2c\u4e09\u4e2a\u662f\u89e6\u6478\u7ed3\u675f\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u7528\u8fd9\u4e09\u4e2a\u65b9\u6cd5\u6765\u76d1\u542c\u6211\u4eec\u7684\u52a8\u4f5c<\/p>\n<pre class=\"hljs cs\"><code class=\"language-javascript hljs\">\t<span class=\"hljs-function\"><span class=\"hljs-keyword\">private<\/span> <span class=\"hljs-title\">touch_begin<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">event<\/span>:egret.TouchEvent<\/span>)\r\n\t<\/span>{\r\n\t\t<span class=\"hljs-keyword\">this<\/span>._touchStatus = <span class=\"hljs-literal\">true<\/span>;\r\n\t\t<span class=\"hljs-keyword\">this<\/span>._container.x = <span class=\"hljs-keyword\">event<\/span>.stageX - <span class=\"hljs-number\">70<\/span>;\r\n\t\t<span class=\"hljs-keyword\">this<\/span>._container.y = <span class=\"hljs-keyword\">event<\/span>.stageY - <span class=\"hljs-number\">70<\/span>;\r\n\t}\r\n\t<span class=\"hljs-function\"><span class=\"hljs-keyword\">private<\/span> <span class=\"hljs-title\">touch_end<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">event<\/span>:egret.TouchEvent<\/span>)\r\n\t<\/span>{\r\n\t\t<span class=\"hljs-keyword\">this<\/span>._touchStatus = <span class=\"hljs-literal\">false<\/span>;\r\n\t}<\/code><\/pre>\n<p>\u59ff\u52bf\u8981\u5feb\uff0c\u8001\u54e5\u7a33\uff0c\u91cd\u70b9\u6765\u4e86\uff0c\u79c1\u6709\u5c01\u88c5private \u5f53\u89e6\u6478\u5c4f\u5e55\u65f6\u5019\u5f00\u542f \u89e6\u6478true\uff0c\u76d1\u542c\u6211\u5f53\u524d\u89e6\u6478\u7684\u4f4d\u7f6e-70\u5c31\u662f\u6240\u5728\u56fe\u7247\u7684\u4f4d\u7f6e\uff0c\uff0c\u8fd9\u4e2a\u6709\u4e00\u4e9b\u7ed5\uff0c\u4e0d\u61c2\u7684\u8001\u54e5\u4eec\u53ef\u4ee5\u7ffb\u4e0a\u9762\u7684\u4ee3\u7801\uff0c\u5f53\u79bb\u5f00\u65f6\u5019\u5173\u95ed\u89e6\u6478,<\/p>\n<pre class=\"hljs kotlin\"><code class=\"language-javascript hljs\">\t<span class=\"hljs-keyword\">private<\/span> touch_move(event:egret.TouchEvent)\r\n\t{\r\n\t\t<span class=\"hljs-keyword\">if<\/span>(<span class=\"hljs-keyword\">this<\/span>._touchStatus)\r\n\t\t{\r\n\t\t\t<span class=\"hljs-keyword\">this<\/span>._container.x = event.stageX - <span class=\"hljs-number\">70<\/span>;\r\n\t\t\t<span class=\"hljs-keyword\">this<\/span>._container.y = event.stageY - <span class=\"hljs-number\">70<\/span>;\r\n\t\t\t\r\n\t\t\t<span class=\"hljs-keyword\">this<\/span>._bigBmp.x = event.stageX * (<span class=\"hljs-keyword\">this<\/span>.scaleWH - <span class=\"hljs-number\">1<\/span>) * - <span class=\"hljs-number\">1<\/span> + <span class=\"hljs-number\">70<\/span>;\r\n\t\t\t<span class=\"hljs-keyword\">this<\/span>._bigBmp.y = event.stageY * (<span class=\"hljs-keyword\">this<\/span>.scaleWH - <span class=\"hljs-number\">1<\/span>) * - <span class=\"hljs-number\">1<\/span> + <span class=\"hljs-number\">70<\/span>;\r\n\t\t}\r\n\t}<\/code><\/pre>\n<p>\u6700\u540e\u68c0\u6d4b\u6211\u9f20\u6807\u79fb\u52a8\uff0c\u89e6\u53d1touchStatus = true \u6267\u884c \u4ee5\u4e0b\u4ee3\u7801\uff0c\u3002\u3002\u3002\u524d\u4e24\u4e2a\u662f\u8ba1\u7b97\u51fa\u6211\u9f20\u6807\u4e0e\u653e\u5927\u955c\u4e4b\u95f4\u7684\u8ddd\u79bb\uff0c\u540e\u4e24\u4e2a\u662f\u8ba1\u7b97\u516c\u5f0f\uff0c \u5f53\u524d\u4f4d\u7f6e * \u653e\u5927\u500d\u6570-\u5b50\u500d\u6570\u3002 * \u00a0&#8211; \u5b50\u500d\u6570 + \u504f\u79fb\u5ea6<\/p>\n<p>\u6069\u3002\u3002\u3002\u5c31\u662f\u8fd9\u6837\uff0c\u4eca\u5929\u53c8\u662f\u4ee3\u7801\u6ee1\u6ee1\u7684\u4e00\u5929\uff0c\u5404\u4f4d\u8001\u54e5\u4e0b\u6b21\u54b1\u4eec\u63a5\u7740\u5520\uff01<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6458\u8981: \u6536\u5230\u6211\u5e08\u7236\u7684\u542f\u53d1\uff0c\u505a\u4e86\u4e00\u4e2a\u653e\u5927\u955c\u7279\u6548\uff0c\u5c0f\u7684\u77e5\u8bc6\u901a\u8fc7\u4e0d\u65ad\u79ef\u7d2f\u5c31\u53d8\u6210\u4e86\u5927\u7a0b\u5e8f\u3002 \u5404\u4f4d\u8001\u54e5\u5750\u7a33\u4e86\uff0c\u5c0f\u5f1f\u6211\u5f00\u59cb [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":144,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[15],"_links":{"self":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/81"}],"collection":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=81"}],"version-history":[{"count":2,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions"}],"predecessor-version":[{"id":819,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions\/819"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/media\/144"}],"wp:attachment":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}