{"id":192288,"date":"2013-09-02T23:15:02","date_gmt":"2013-09-02T19:15:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=192288"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=192288","title":{"rendered":"<span class=\"post_title\">\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 Easel.js \u0438 Box2d \u043d\u0430 Canvas<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041e\u0434\u0438\u043d \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0439 <a href=\"http:\/\/www.luxahoy.com\/\">\u0438\u0433\u0440\u044b<\/a> \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0434\u0432\u0435 \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0443\u0442\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: <a href=\"http:\/\/easeljs.com\/\">Easel.js<\/a>\u00a0\u0438\u00a0<a href=\"http:\/\/code.google.com\/p\/box2dweb\/\">Box2dWeb<\/a>. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u0438\u0433\u0440\u043e\u0432\u044b\u0447 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0433\u0440\u044b \u0442\u0430\u043a, \u0447\u0442\u043e \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 box2d \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 X, Y, \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043d\u0430 \u0434\u0438\u0441\u043f\u043b\u0435\u0435 \u0432 easel.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043a \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 box2d \u0438 easel. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u043c\u0438\u0440\u0430 box2d, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0439\u0442\u0435 <a href=\"http:\/\/blog.sethladd.com\/2011\/08\/box2d-orientation-for-javascript.html\">\u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b<\/a> \u043f\u043e box2d \u043e\u0442 \u0421\u0435\u0442\u0430 \u041b\u044d\u0434\u0430. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 easel, \u0442\u043e \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 <a href=\"http:\/\/easeljs.com\/docs\/\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439<\/a>, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b \u043d\u0430 \u0441\u0446\u0435\u043d\u0443 \u0438 \u0438\u0437\u0443\u0447\u0438\u043b\u0438 \u0432\u0441\u044e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u044e \u0434\u0438\u0441\u043f\u043b\u0435\u044f (\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430: \u043e\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u0449\u0438\u0445 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 \u0441 Flash \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c). <\/p>\n<p>  \u041d\u0443, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0433\u043b\u0443\u0431\u0438\u043c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438. \u041c\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0445 \u0440\u043e\u0437\u043e\u0432\u044b\u0445 \u043f\u0442\u0438\u0446.<\/p>\n<p>  <a href=\"http:\/\/www.luxanimals.com\/tutorials\/birds\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435<\/a> \u2014 <a href=\"http:\/\/www.luxanimals.com\/tutorials\/birds\/easel_b2d_source.zip\">\u0421\u043a\u0430\u0447\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a><\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0443\u0436\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u044b \u0440\u0430\u0431\u043e\u0442\u044b\u00a0Easel \u0438\u00a0Box2d, \u043c\u044b \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438 \u0443\u0433\u043b\u0443\u0431\u0438\u043c\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0432\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 <a href=\"http:\/\/www.luxanimals.com\/tutorials\/birds\/easel_b2d_source.zip\">zip \u0430\u0440\u0445\u0438\u0432<\/a> \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 \u0432 Easel \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430 \u0441\u0446\u0435\u043d\u0443 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u0412\u043e\u0442 \u043a\u0430\u043a \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0442\u0438\u0446 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0446\u0438\u043a\u043b\u0438\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u0441\u0435 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u043a\u043e\u0434\u0430 \u0438\u0437 \u043d\u0438\u0436\u0435-\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0445 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0435\u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0442\u0440\u044b\u0432\u043a\u0430\u043c\u0438 \u0438\u0437 demo.js. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0434, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c <a href=\"http:\/\/www.luxanimals.com\/tutorials\/birds\/easel_b2d_source.zip\">zip \u0430\u0440\u0445\u0438\u0432<\/a>.<\/p>\n<pre><code class=\"javascript\">var tick = function(dt, paused) { \tbirdDelayCounter++; \tif(birdDelayCounter % 10 === 0) {  \/\/ \u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430, \u043f\u0442\u0438\u0446\u044b \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0444\u0440\u0435\u0439\u043c\u0435 \t\tbirdDelayCounter = 0; \t\tbirds.spawn(); \t} } <\/code><\/pre>\n<pre><code class=\"javascript\">var spawn = function() { \tvar birdBMP = new Bitmap(&quot;images\/bird.png&quot;); \tbirdBMP.x = Math.round(Math.random()*500); \tbirdBMP.y = -30; \tbirdBMP.regX = 25;   \/\/ \u0412\u0430\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043a \u0446\u0435\u043d\u0442\u0440\u0443 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \tbirdBMP.regY = 25;  \tstage.addChild(birdBMP); } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u043c. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043f\u0442\u0438\u0446\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0446\u0435\u043d\u0435 \u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c \u043d\u0430\u0443\u0433\u0430\u0434 \u0425 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043d\u0430 \u0432\u0435\u0440\u0445\u0443 \u043f\u043e\u043b\u043e\u0442\u043d\u0430. \u0421\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0439. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0441\u0434\u0432\u0438\u043d\u0443\u0442\u044c \u0435\u0433\u043e \u0438 \u0442.\u0434. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0437\u0430\u043a\u043e\u043d\u044b \u043a \u0441\u0432\u043e\u0435\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0432 box2d.<\/p>\n<p>  regX \u0438 regY (\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438) \u0432\u0430\u0436\u043d\u044b, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 easel \u043a box2d. \u042d\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043e \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e box2d \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438\u043c\u0435\u044e\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432\u0432\u0435\u0440\u0445\u0443 \u0441\u043b\u0435\u0432\u0430 \u0443 easel \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0430\u0448\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0443\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0430 \u0441\u0446\u0435\u043d\u0443, \u043f\u043e\u0440\u0430 \u043f\u043e\u0441\u043b\u0430\u0442\u044c \u0438\u0445 \u0432 box2d \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u044f\u044e\u0449\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/p>\n<pre><code class=\"javascript\">box2d.createBird(birdBMP); <\/code><\/pre>\n<pre><code class=\"javascript\">var createBird = function(skin) { \tvar birdFixture = new b2FixtureDef; \tbirdFixture.density = 1; \tbirdFixture.restitution = 0.6; \tbirdFixture.shape = new b2CircleShape(24 \/ SCALE);   \/\/  \u0428\u0438\u0440\u0438\u043d\u0430 bird.png \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043c\u0438\u0440\u043e\u0432\u044b\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u043e\u043c \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \tvar birdBodyDef = new b2BodyDef; \tbirdBodyDef.type = b2Body.b2_dynamicBody; \tbirdBodyDef.position.x = skin.x \/ SCALE;  \/\/ \u0420\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435 skin x \u0438 y  \u043d\u0430 box2d \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u0443\u0436\u043d\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \tbirdBodyDef.position.y = skin.y \/ SCALE; \tvar bird = world.CreateBody(birdBodyDef); \tbird.CreateFixture(birdFixture); \tbodies.push(bird); } <\/code><\/pre>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043a\u0440\u0443\u0433\u043b\u043e\u0435 box2d \u0442\u0435\u043b\u043e \u0432 \u0442\u043e\u043c \u0436\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043a\u0430\u043a \u0438 bitmap. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043f\u0442\u0438\u0446\u044b \u043d\u0435 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d\u043e \u043a box2d \u043e\u0431\u044a\u0435\u043a\u0442\u0443. \u0411\u0435\u0437 debug canvas \u0432\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043a\u0440\u0443\u0433\u043b\u044b\u0439 box2d \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0438 \u043f\u0442\u0438\u0446\u0430 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e\u0439. \u041a\u0430\u043a \u043c\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0442\u0435\u043b\u0430 box2d?<\/p>\n<p>  &#8230;Actors! Actors \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0439 box2d \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u044d\u0442\u043e \u043e\u043d\u0438 \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d\u044b \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 box2d \u0442\u0435\u043b \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u044d\u0442\u043e.<\/p>\n<pre><code class=\"javascript\">var actor = new actorObject(bird, skin); bird.SetUserData(actor);  \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 actor \u043a\u0430\u043a \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0442\u0435\u043b\u0435 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0438\u043c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"javascript\">var actorObject = function(body, skin) { \tthis.body = body; \tthis.skin = skin; \tthis.update = function() { \/\/ \u043f\u0435\u0440\u0435\u0432\u043e\u0434 box2d \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u0438 \t\tthis.skin.rotation = this.body.GetAngle() * (180 \/ Math.PI); \t\tthis.skin.x = this.body.GetWorldCenter().x * SCALE; \t\tthis.skin.y = this.body.GetWorldCenter().y * SCALE; \t} \tactors.push(this); } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 actor \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0435\u0441\u043b\u0438 \u0431\u044b \u0432\u044b \u0445\u043e\u0442\u0435\u043b\u0438, \u0442\u043e \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u0447\u0442\u0438 \u043b\u044e\u0431\u044b\u0445 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 (\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0438 \u0442.\u0434.). \u041c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430 \u0434\u043b\u044f box2d \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430.<\/p>\n<pre><code class=\"javascript\">\/\/ \u043f\u0435\u0440\u0435\u0434 world.step for(var i=0, l=actors.length; i&lt;l; i++) {      actors&lt;i&gt;.update(); } <\/code><\/pre>\n<p>  \u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0432\u0441\u0451, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 box2d \u0442\u0435\u043b\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0442\u0435\u043b\u043e \u0438 \u0435\u0433\u043e \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0435, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0435\u043b\u043e \u0432 \u043c\u0430\u0441\u0441\u0438\u0432. \u0422\u0435\u043b\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u044b \u043f\u0435\u0440\u0435\u0434 \u043a\u0430\u0436\u0434\u044b\u043c \u0448\u0430\u0433\u043e\u043c.<\/p>\n<pre><code class=\"javascript\">\/\/ \u0434\u043e world.step for(var i=0, l=bodiesToRemove.length; i&lt;l; i++) { \tremoveActor(bodiesToRemove&lt;i&gt;.GetUserData());  \/\/ get the actor object in the user data of the body and send to removeActor function \tbodiesToRemove&lt;i&gt;.SetUserData(null); \tworld.DestroyBody(bodiesToRemove&lt;i&gt;); } \/\/ \u043f\u043e\u0441\u043b\u0435 world.step if(bodies.length &gt; 30) {      bodiesToRemove.push(bodies[0]);      bodies.splice(0,1); } <\/code><\/pre>\n<pre><code class=\"javascript\">var removeActor = function(actor) { \tstage.removeChild(actor.skin); \tactors.splice(actors.indexOf(actor),1); } <\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c! \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 box2d \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043f\u0440\u0438 \u0441\u0442\u043e\u043b\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0438, \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u0438 \u0442.\u0434. \u042f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u043c\u044b \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u0441 \u044d\u0442\u0438\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u043c.<\/p>\n<p>  <a href=\"http:\/\/www.luxanimals.com\/tutorials\/birds\">\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435<\/a> \u2014 <a href=\"http:\/\/www.luxanimals.com\/tutorials\/birds\/easel_b2d_source.zip\">\u0421\u043a\u0430\u0447\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a><\/p>\n<p>  Author Justin Schrader<br \/>  <a href=\"http:\/\/www.luxanimals.com\/blog\/article\/combining_easel_box2d\">www.luxanimals.com\/blog\/article\/combining_easel_box2d<\/a> \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/192288\/\"> http:\/\/habrahabr.ru\/post\/192288\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041e\u0434\u0438\u043d \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0439 <a href=\"http:\/\/www.luxahoy.com\/\">\u0438\u0433\u0440\u044b<\/a> \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0434\u0432\u0435 \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0443\u0442\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: <a href=\"http:\/\/easeljs.com\/\">Easel.js<\/a>\u00a0\u0438\u00a0<a href=\"http:\/\/code.google.com\/p\/box2dweb\/\">Box2dWeb<\/a>. \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u0441\u043d\u043e\u0432\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u0438\u0433\u0440\u043e\u0432\u044b\u0447 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u0433\u0440\u044b \u0442\u0430\u043a, \u0447\u0442\u043e \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 box2d \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 X, Y, \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043e\u0432 \u043d\u0430 \u0434\u0438\u0441\u043f\u043b\u0435\u0435 \u0432 easel.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-192288","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/192288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=192288"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/192288\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=192288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=192288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=192288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}