{"id":244,"date":"2016-11-12T17:58:51","date_gmt":"2016-11-12T09:58:51","guid":{"rendered":"http:\/\/blog.xrhoujie.com\/?p=244"},"modified":"2021-10-19T10:38:47","modified_gmt":"2021-10-19T02:38:47","slug":"%e7%99%bd%e9%b9%ad%e5%bc%80%e5%8f%91-%e8%b4%aa%e5%90%83%e8%9b%87%e5%a4%a7%e4%bd%9c%e6%88%98%e4%ba%8c","status":"publish","type":"post","link":"http:\/\/blog.xrhoujie.com\/?p=244","title":{"rendered":"\u767d\u9e6d\u5f00\u53d1-\u4e03\u5f69\u8d2a\u5403\u86c7(\u4e8c)"},"content":{"rendered":"<p>\u4e0a\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u6211\u4eec\u9879\u76ee\u7684\u5404\u4e2a\u6587\u4ef6\u5939\uff0c\u63a5\u4e0b\u6765\u5f00\u59cb\u4ecb\u7ecd\u679c\u5b9e\u7bc7\u3002<\/p>\n<p>class Food extends egret.Sprite {<\/p>\n<p>\/**<br \/>\n* \u98df\u7269\u989c\u8272<br \/>\n*\/<br \/>\nprivate static colorList: number[] =<br \/>\n[0x70f3ff, 0xff461f, 0x00bc12, 0x21a675, 0x4c221b, 0xbf242a, 0x161823, 0xffa400,];<br \/>\n\/\/private static colorList: number[] =<br \/>\n\/\/[0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000, 0xff0000,];<\/p>\n<p>\/**<br \/>\n* @param x \u6a2a\u5750\u6807<br \/>\n* @param y \u7eb5\u5750\u6807<br \/>\n* @param r \u534a\u5f84<br \/>\n*\/<br \/>\npublic constructor(x: number, y: number, r: number) {<br \/>\nsuper();<br \/>\nthis.init(x, y, r);<br \/>\n\/\/ var timer:egret.Timer = new egret.Timer(2000,0);<br \/>\n\/\/ timer.addEventListener(egret.TimerEvent.TIMER,this.timerFunc,this);<br \/>\n\/\/ timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE,this.timerComFunc,this);<br \/>\n\/\/timer.start();<br \/>\n}<\/p>\n<p>private food: egret.Shape;<br \/>\npublic color: number;<\/p>\n<p>\/**<br \/>\n* \u521d\u59cb\u5316<br \/>\n*<br \/>\n* 1.\u7ed8\u5236\u679c\u5b9e<br \/>\n*\/<\/p>\n<p>\/\/ private timerComFunc()<br \/>\n\/\/ {<br \/>\n\/\/ console.log(&#8220;\u8ba1\u65f6\u7ed3\u675f&#8221;);<br \/>\n\/\/ }<\/p>\n<p>private init(x: number, y: number, r: number): void {<\/p>\n<p>\/\/\u83b7\u53d6\u968f\u673a\u989c\u8272<br \/>\nthis.color = this.randomColor();<\/p>\n<p>this.food = new egret.Shape();<br \/>\nthis.food.graphics.beginFill(this.color);<br \/>\nthis.food.graphics.drawCircle(0, 0, r);<br \/>\nthis.food.graphics.endFill();<\/p>\n<p>this.food.x = r;<br \/>\nthis.food.y = r;<\/p>\n<p>\/\/\u4f4d\u7f6e<br \/>\nthis.x = x;<br \/>\nthis.y = y;<\/p>\n<p>this.addChild(this.food);<br \/>\negret.Tween.get(this.food,{loop:true}).to({alpha:.0 },300,egret.Ease.circIn).to({alpha:1 },300,egret.Ease.circIn);<br \/>\n}<\/p>\n<p>\/**<br \/>\n* \u83b7\u53d6\u968f\u673a\u7684\u989c\u8272<br \/>\n*\/<br \/>\nprivate randomColor(): number {<br \/>\n\/\/ return Food.colorList[Math.round(Math.random() * Food.colorList.length)];<br \/>\nreturn parseInt(&#8220;0x&#8221; + (&#8220;000000&#8221; + ((Math.random() * 16777215 + 0.5) &gt;&gt; 0).toString(16)).slice(-6));<br \/>\n}<\/p>\n<p>\/**<br \/>\n* \u88ab\u5403<br \/>\n*\/<br \/>\npublic onEat() {<br \/>\nthis.parent.removeChild(this);<br \/>\n}<br \/>\n}<\/p>\n<p>\u989c\u8272\u6570\u7ec4\u5f97\u5230\u7684\u662f\u679c\u5b9e\u7684\u989c\u8272\uff0c\u4e0b\u9762\u7684\u968f\u673a\u53d6\u8272\u662f\u4ece\u6570\u7ec4\u91cc\u9762\u53d6\uff0c<\/p>\n<p>\u7f13\u52a8\u52a8\u753b\u4f7f\u7684\u6211\u4eec\u679c\u5b9e\u66f4\u52a0\u5177\u6709\u52a8\u6548\uff0c\u6700\u540e\u6267\u884c\u88ab\u5403\u64cd\u4f5c\uff0c<\/p>\n<p>\u4eca\u5929\u53c8\u662f\u4ee3\u7801\u6ee1\u6ee1\u7684\u4e00\u5929<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u6211\u4eec\u9879\u76ee\u7684\u5404\u4e2a\u6587\u4ef6\u5939\uff0c\u63a5\u4e0b\u6765\u5f00\u59cb\u4ecb\u7ecd\u679c\u5b9e\u7bc7\u3002 class Food extends egret.S [&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":[],"_links":{"self":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/244"}],"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=244"}],"version-history":[{"count":3,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/244\/revisions"}],"predecessor-version":[{"id":818,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/244\/revisions\/818"}],"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=244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=244"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}