{"id":282,"date":"2017-07-17T17:16:46","date_gmt":"2017-07-17T09:16:46","guid":{"rendered":"http:\/\/blog.xrhoujie.com\/?p=282"},"modified":"2021-10-19T10:48:09","modified_gmt":"2021-10-19T02:48:09","slug":"create-js%e5%bc%80%e5%8f%91%e5%89%aa%e5%88%80%e7%9f%b3%e5%a4%b4%e5%b8%83%e6%b8%b8%e6%88%8f%ef%bc%88%e4%b8%80%ef%bc%89","status":"publish","type":"post","link":"http:\/\/blog.xrhoujie.com\/?p=282","title":{"rendered":"Create.js\u5f00\u53d1\u526a\u5200\u77f3\u5934\u5e03\u6e38\u620f\uff08\u4e00\uff09"},"content":{"rendered":"<p>\u5f88\u957f\u65f6\u95f4\u6ca1\u6709\u5199\u535a\u5ba2\u4e86\uff0c\u4e0d\u77e5\u9053\u5927\u5bb6\u6709\u6ca1\u6709\u60f3\u6211\uff0c\u54c8\u54c8\u54c8\uff0c\u4eca\u5929\u5206\u4eab\u4e00\u6b3e\u6e38\u620f \u53eb\u505a\u526a\u5200\u77f3\u5934\u5e03\uff0c\u60f3\u5fc5\u5927\u5bb6\u5c0f\u65f6\u5019\u90fd\u73a9\u8fc7\uff0c\u4f20\u9001\u95e8\u5165\u53e3:<a href=\"https:\/\/github.com\/894658027\/HTML5-Games\/tree\/master\/CreateJs\/finger-guessing%20game\">https:\/\/github.com\/894658027\/HTML5-Games\/tree\/master\/CreateJs\/finger-guessing%20game<\/a>\uff0c\u5982\u679c\u4f60\u60f3\u76f4\u63a5\u73a9\u8bf7\u76f4\u63a5\u70b9\u51fb\u94fe\u63a5\uff0c\u8bdd\u4e0d\u591a\u8bf4\u76f4\u63a5\u4e0a\u4ee3\u7801\uff0c<\/p>\n<p>\u9996\u5148html\u4ee3\u7801\uff1a<\/p>\n<div>\n<div>&lt;canvasid=&#8221;gameView&#8221;width=&#8221;1280&#8243;height=&#8221;720&#8243;&gt;&lt;\/canvas&gt;<\/div>\n<\/div>\n<div>js\u6838\u5fc3\u4ee3\u7801\uff1a<\/div>\n<div><\/div>\n<div>\u6587\u4ef6\u5165\u53e3\u4e0e\u914d\u7f6e\uff1a(\u8fd9\u91cc\u76f4\u63a5\u7528es6\u6765\u7f16\u5199\u7684)<\/div>\n<div><\/div>\n<div>\n<div>window.init= () =&gt; {<\/div>\n<div>letloadingValue=$(&#8220;#loading span&#8221;);<\/div>\n<div>window.queue=newc.LoadQueue();<\/div>\n<div>window.queue.installPlugin(createjs.Sound);<\/div>\n<div>window.queue.addEventListener(&#8220;complete&#8221;, (ev)=&gt;{<\/div>\n<div>window.game=newGame();<\/div>\n<div>$(&#8220;#loading&#8221;).hide();<\/div>\n<div>});<\/div>\n<div>window.queue.addEventListener(&#8220;progress&#8221;, (ev)=&gt;{<\/div>\n<div>loadingValue.text((ev.progress*100).toFixed() +&#8221;%&#8221;);<\/div>\n<div>})<\/div>\n<div>window.queue.loadManifest([<\/div>\n<div>{ id: &#8220;pointsound&#8221;, src: &#8220;music\/pointsound.mp3&#8221; },<\/div>\n<div>{ id: &#8220;noMuc&#8221;, src: &#8220;music\/noMuc.mp3&#8221; },<\/div>\n<div>{ id: &#8220;s2&#8221;, src: &#8220;music\/s2.mp3&#8221; },<\/div>\n<div>{ id: &#8220;nzb&#8221;, src: &#8220;music\/nzb.mp3&#8221; },<\/div>\n<div>])<\/div>\n<div>window.queue.loadManifest([<\/div>\n<div>{ id: &#8220;1&#8221;, src: &#8220;image\/assest\/1.png&#8221;},<\/div>\n<div>{ id: &#8220;2&#8221;, src: &#8220;image\/assest\/2.png&#8221;},<\/div>\n<div>{ id: &#8220;3&#8221;, src: &#8220;image\/assest\/3.png&#8221;},<\/div>\n<div>{ id: &#8220;4&#8221;, src: &#8220;image\/assest\/6.png&#8221;},<\/div>\n<div>{ id: &#8220;5&#8221;, src: &#8220;image\/assest\/5.png&#8221;},<\/div>\n<div>{ id: &#8220;6&#8221;, src: &#8220;image\/assest\/4.png&#8221;},<\/div>\n<div>{ id: &#8220;panel&#8221;, src: &#8220;image\/assest\/panel.png&#8221;},<\/div>\n<div>{ id: &#8220;xiong&#8221;, src: &#8220;image\/assest\/xiong.png&#8221;},<\/div>\n<div>{ id: &#8220;guang&#8221;, src: &#8220;image\/assest\/guang.png&#8221;},<\/div>\n<div>{ id: &#8220;scBtn&#8221;, src: &#8220;image\/direPic\/scBtn.png&#8221;},<\/div>\n<div>{ id: &#8220;sgBtn&#8221;, src: &#8220;image\/direPic\/sgBtn.png&#8221;},<\/div>\n<div>{ id: &#8220;pjBtn&#8221;, src: &#8220;image\/direPic\/middle.png&#8221;},<\/div>\n<div>{ id: &#8220;score&#8221;, src: &#8220;image\/direPic\/score.png&#8221;},<\/div>\n<div>]);<\/div>\n<div>}<\/div>\n<div>\u4e0e\u52a0\u8f7d\u5185\u5bb9\u4e0e\u914d\u7f6e\u5165\u53e3\u6587\u4ef6\u642d\u914d\u5b8c\u6210\uff0c<\/div>\n<div><\/div>\n<\/div>\n<div><\/div>\n<div>\n<div>classGame {<\/div>\n<div>constructor(){<\/div>\n<div>this.stage=newc.Stage(&#8220;gameView&#8221;);<\/div>\n<div>c.Touch.enable(this.stage);<\/div>\n<div>this.stage.enableMouseOver();<\/div>\n<div>this.width=this.stage.canvas.width;<\/div>\n<div>this.height=this.stage.canvas.height;<\/div>\n<div>this.gameDataSheet();<\/div>\n<div>this.render();<\/div>\n<div>createjs.Sound.play(&#8220;s2&#8221;, createjs.Sound.INTERRUPT_NONE,0,0,-1,1,0);<\/div>\n<div>}<\/div>\n<div>\u83b7\u53d6\u821e\u53f0\uff0c\u89e6\u5c4f\u4e8b\u4ef6\uff0c\u575a\u633a\u9f20\u6807\u4e8b\u4ef6\uff0c\u7b49\u5bbd\uff0c\u7b49\u9ad8\uff0clocalstory\u5b58\u50a8\uff0crequireAnimationFrame\u8ba1\u65f6\u5668\uff0cbgm\u64ad\u653e\u65e0\u9650\u5faa\u73af\uff0c<\/div>\n<\/div>\n<div>ok \uff0c\u63a5\u4e0b\u6765\u662f\u5fc3\u8df3\u8ba1\u65f6\u4ee3\u7801\uff0c<\/div>\n<div>\n<div>render(){<\/div>\n<div>this.stage.update();<\/div>\n<div>window.requestAnimationFrame(()=&gt;{<\/div>\n<div>this.render();<\/div>\n<div>})<\/div>\n<div>}<\/div>\n<div>\u8fd9\u91cc\u5c31\u4e0d\u591a\u8bf4\u4e86 \uff0c\u63a5\u4e0b\u6765\u662f localstory\u63a5\u53d7\u952e\u503c\u8bbe\u7f6e\u4e0e\u6e38\u620f\u573a\u666f\u6dfb\u52a0<\/div>\n<\/div>\n<div><\/div>\n<div>\n<div>gameDataSheet(){<\/div>\n<div>window.ceil=window.localStorage.vision;<\/div>\n<div>window.score=0;<\/div>\n<div>console.log(ceil);<\/div>\n<div>this.firstScreen();<\/div>\n<div>}<\/div>\n<\/div>\n<div>\u5176\u4f59\u7684\u8bf7\u770b\u4e0b\u4e00\u7bc7\uff1a\u5176\u4e2d\u5305\u542b\uff0c\u5e03\u5c40\u4e0e\u6e38\u620f\u73a9\u6cd5\u4e3b\u903b\u8f91\uff0c\u5f97\u5206\u529f\u80fd\u8ba1\u7b97\u7d2f\u52a0\uff0c\u8ba1\u65f6\u5668\u7b49\uff0c<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5f88\u957f\u65f6\u95f4\u6ca1\u6709\u5199\u535a\u5ba2\u4e86\uff0c\u4e0d\u77e5\u9053\u5927\u5bb6\u6709\u6ca1\u6709\u60f3\u6211\uff0c\u54c8\u54c8\u54c8\uff0c\u4eca\u5929\u5206\u4eab\u4e00\u6b3e\u6e38\u620f \u53eb\u505a\u526a\u5200\u77f3\u5934\u5e03\uff0c\u60f3\u5fc5\u5927\u5bb6\u5c0f\u65f6\u5019\u90fd\u73a9\u8fc7\uff0c\u4f20 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":179,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[27],"_links":{"self":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/282"}],"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=282"}],"version-history":[{"count":2,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/282\/revisions"}],"predecessor-version":[{"id":830,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/posts\/282\/revisions\/830"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=\/wp\/v2\/media\/179"}],"wp:attachment":[{"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=282"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.xrhoujie.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}