{"id":177,"date":"2017-09-03T00:33:46","date_gmt":"2017-09-02T15:33:46","guid":{"rendered":"https:\/\/www.dogrow.net\/hp\/?p=177"},"modified":"2017-09-04T00:44:21","modified_gmt":"2017-09-03T15:44:21","slug":"blog22","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/hp\/blog22\/","title":{"rendered":"(22) CREATEJS\u3067\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3 (#1)"},"content":{"rendered":"<p>CREATEJS\u3092\u4f7f\u3063\u3066JavaScript\u3067\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u3055\u305b\u3066\u307f\u308b\u3002<\/p>\n<p>\u516c\u5f0f\u30b5\u30a4\u30c8\u306f\u3053\u3061\u3089\uff08\u2193\uff09 TOP\u30da\u30fc\u30b8\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u304c\u3068\u3063\u3066\u3082\u30af\u30fc\u30eb\u3067\u3059\u3002<br \/>\n<a href=\"\/\/createjs.com\/\" target=\"_blank\"><img decoding=\"async\" src=\"\/\/www.dogrow.net\/hp\/wp-content\/uploads\/2017\/09\/Image1.png\" alt=\"\" \/><\/a><\/p>\n<h1 class=\"my_h\">\u25a0\u7df4\u7fd2\u30c6\u30fc\u30de<\/h1>\n<p>\u307e\u305a\u306f\u7c21\u5358\u306a\u3082\u306e\u304b\u3089\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u77e9\u5f62\u67a0\u5185\u3092\u30dc\u30fc\u30eb\u304c\u8ee2\u304c\u308b\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b\u3002<br \/>\n\u58c1\u306b\u5f53\u305f\u308b\u3068\u6642\u8a08\u56de\u308a\u306b\uff19\uff10\u5ea6\u56de\u8ee2\u3057\u3066\u8df3\u306d\u8fd4\u308b\u3002\uff08\u51e6\u7406\u7c21\u7565\u5316\u306e\u305f\u3081\u7269\u7406\u6cd5\u5247\u3068\u306f\u7570\u306a\u308b\u3002\uff09<br \/>\n<a href=\"\/\/www.dogrow.net\/hp\/sample\/00022\" target=\"_blank\"><br \/>\n<img decoding=\"async\" src=\"\/\/www.dogrow.net\/hp\/wp-content\/uploads\/2017\/09\/Image3.png\" alt=\"\" \/><br \/>\n\u5b9f\u884c\u30b5\u30f3\u30d7\u30eb\u306f\u3053\u3061\u3089\u3067\u3059\u3002<\/a><\/p>\n<h1 class=\"my_h\">\u25a0\u30d7\u30ed\u30b0\u30e9\u30e0<\/h1>\n<h3 class=\"my_h\">index.html<\/h3>\n<p>\u30fb6\u884c\u76ee\uff1aCREATEJS\u3092\u8aad\u307f\u8fbc\u3080\u3002<br \/>\n\u30fb7\u884c\u76ee\uff1a\u81ea\u4f5c\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8aad\u307f\u8fbc\u3080\u3002<br \/>\n\u30fb9\u884c\u76ee\uff1a\u30da\u30fc\u30b8\u30ed\u30fc\u30c9\u5b8c\u4e86\u6642\u306b\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u958b\u59cb\u3059\u308b\u3002ID=view\u306e canvas\u306b\u8868\u793a\u3055\u305b\u308b\u3002<br \/>\n\u30fb15\u884c\u76ee\uff1a\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8868\u793a\u3059\u308b canvas \u3092\u7528\u610f\u3059\u308b\u3002<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;ja&quot;&gt;\r\n&lt;head&gt;\r\n&lt;meta charset=&quot;utf-8&quot;&gt;\r\n&lt;script src=&quot;\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.11.3\/jquery.min.js&quot;&gt;&lt;\/script&gt;\r\n&lt;script src=&quot;\/\/code.createjs.com\/createjs-2015.05.21.min.js&quot;&gt;&lt;\/script&gt;\r\n&lt;script src=&quot;.\/test.js&quot;&gt;&lt;\/script&gt;\r\n&lt;script&gt;\r\n$(document).ready(function(){\r\n  var obj = new CjTest({id:'view'});\r\n});\r\n&lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;canvas id=&quot;view&quot; width=&quot;800&quot; height=&quot;600&quot; style=&quot;border:2px #000 solid;background:#ffe&quot;&gt;&lt;\/canvas&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<h3 class=\"my_h\">test.js<\/h3>\n<p>\u81ea\u4f5c\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u30b9\u30af\u30ea\u30d7\u30c8\u3002<br \/>\n\u30fb30FPS\u3067\u30dc\u30fc\u30eb\u304c canvas\u5185\u3092\u8ee2\u304c\u308b\u3002<br \/>\n\u30fb\u30e1\u30bd\u30c3\u30c9\u306f3\u500b init(), makeBall(), movrBall()<br \/>\n\u30fb18\u884c\u76ee\uff1a30FPS\u306e\u5468\u671f\u51e6\u7406\u3092\u8d77\u52d5\u3059\u308b\u3002\u3053\u306e\u4e2d\u3067\u30dc\u30fc\u30eb\u306e\u79fb\u52d5\u3068\u63cf\u753b\u66f4\u65b0\u3092\u884c\u3046\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction CjTest(args){\r\n  this.init(args);\r\n}\r\n\/\/ prototype\r\nCjTest.prototype = {\r\n  init: function(args){\r\n    \/\/ create stage\r\n    this.stage  = new createjs.Stage(args.id);\r\n    \/\/ draw ball\r\n    this.canvas = $('#'+args.id);\r\n    this.stageWidth  = this.canvas.attr('width');\r\n    this.stageHeight = this.canvas.attr('height');\r\n    this.makeBall();\r\n    \/\/ start animation\r\n    createjs.Ticker.setFPS(30);\r\n    createjs.Ticker.addEventListener('tick', function(){\r\n      this.moveBall();\r\n      this.stage.update();\r\n    }.bind(this));\r\n  },\r\n  makeBall: function(){\r\n    \/\/ create sprite\r\n    this.sprite = new createjs.Shape();\r\n    \/\/ draw ball\r\n    this.ball_r = 10;\r\n    this.half_r = 5;\r\n    this.sprite.x = this.stageWidth  \/ 2;\r\n    this.sprite.y = this.stageHeight \/ 2;\r\n    this.sprite.graphics.beginFill('#f00').drawCircle(0, 0, this.ball_r);\r\n    this.stage.addChild(this.sprite);\r\n    this.stage.update();\r\n    this.sprite.directionRad = 1;\r\n  },\r\n  moveBall: function(){\r\n    var x, y;\r\n    while(1){\r\n      x = this.sprite.x + Math.cos(this.sprite.directionRad) * 10;\r\n      y = this.sprite.y + Math.sin(this.sprite.directionRad) * 10;\r\n      if(this.half_r &lt;= x &amp;&amp; x &lt; this.stageWidth  - this.half_r &amp;&amp;\r\n         this.half_r &lt;= y &amp;&amp; y &lt; this.stageHeight - this.half_r){\r\n         break;\r\n      }\r\n      this.sprite.directionRad = this.sprite.directionRad + (Math.PI \/ 4);\r\n    }\r\n    this.sprite.x = x;\r\n    this.sprite.y = y;\r\n    this.stage.update();\r\n  }\r\n};\r\n<\/pre>\n<p><a href=\"\/\/www.dogrow.net\/hp\/sample\/00022\" target=\"_blank\">\u5b9f\u884c\u30b5\u30f3\u30d7\u30eb\u306f\u3053\u3061\u3089\u3067\u3059\u3002<\/a><\/p>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>CREATEJS\u3092\u4f7f\u3063\u3066JavaScript\u3067\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u3055\u305b\u3066\u307f\u308b\u3002 \u516c\u5f0f\u30b5\u30a4\u30c8\u306f\u3053\u3061\u3089\uff08\u2193\uff09 TOP\u30da\u30fc\u30b8\u306e\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u304c\u3068\u3063\u3066\u3082\u30af\u30fc\u30eb\u3067\u3059\u3002 \u25a0\u7df4\u7fd2\u30c6\u30fc\u30de \u307e\u305a\u306f\u7c21\u5358\u306a\u3082\u306e\u304b\u3089\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u77e9\u5f62\u67a0\u5185\u3092\u30dc\u30fc\u30eb\u304c\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/hp\/blog22\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,11],"tags":[],"class_list":["post-177","post","type-post","status-publish","format-standard","hentry","category-createjs","category-11"],"views":1914,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/posts\/177","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/comments?post=177"}],"version-history":[{"count":23,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/posts\/177\/revisions"}],"predecessor-version":[{"id":244,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/posts\/177\/revisions\/244"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/media?parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/categories?post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/hp\/wp-json\/wp\/v2\/tags?post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}