{"id":162733,"date":"2012-12-16T00:47:03","date_gmt":"2012-12-15T20:47:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=162733"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=162733","title":{"rendered":"<span class=\"post_title\">\u041a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0433\u0440\u0443 \u0432 \u0441\u0442\u0438\u043b\u0435 Tower Defense<\/span>"},"content":{"rendered":"<div class=\"content html_format\">       \u0416\u0430\u043d\u0440 Tower Defence \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0436\u0430\u043d\u0440\u043e\u0432 \u0438\u0433\u0440 \u043d\u0430 iOS. \u041f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u0442\u043e\u043c\u0443 \u0432\u0435\u0441\u0435\u043b\u043e\u0435 \u0432\u0440\u0435\u043c\u044f\u043f\u0440\u0435\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435, \u0441\u0434\u043e\u0431\u0440\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439 \u0431\u0430\u0448\u0435\u043d \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0442\u043e\u0447\u043a\u0438 \u043e\u0431\u043e\u0440\u043e\u043d\u044b \u043f\u0440\u043e\u0442\u0438\u0432 \u043e\u0440\u0434 \u043c\u043e\u043d\u0441\u0442\u0440\u043e\u0432, \u043f\u044b\u0442\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u044d\u0442\u0443 \u0441\u0430\u043c\u0443\u044e \u043e\u0431\u043e\u0440\u043e\u043d\u0443 \u043f\u0440\u043e\u0440\u0432\u0430\u0442\u044c.<br \/>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 Pablo Ruiz, \u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0439 \u043c\u043d\u043e\u0439 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 <a href=\"http:\/\/www.raywenderlich.com\">raywenderlich.com<\/a>.<br \/>  \u0412 \u044d\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u0433\u0440\u0443 Tower Defense \u0441 \u043d\u0443\u043b\u044f, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Cocos2D.<br \/>  \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u044b \u0432\u044b\u0443\u0447\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<ul>\n<li>\u041a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043e\u043b\u043d\u044b \u0432\u0440\u0430\u0433\u043e\u0432 \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438\u0445 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f. <\/li>\n<li>\u041a\u0430\u043a \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0438\u0445 \u0432\u0440\u0430\u0433\u043e\u0432 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0442\u043e\u0447\u043a\u0430\u043c(waypoint&#8217;\u0430\u043c). <\/li>\n<li>\u041a\u0430\u043a \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u0430\u0448\u043d\u0438 \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u043d\u0430 \u043a\u0430\u0440\u0442\u0435. <\/li>\n<li>\u041a\u0430\u043a \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0431\u0430\u0448\u043d\u0438 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c \u0432\u043e \u0432\u0440\u0430\u0433\u043e\u0432. <\/li>\n<li>\u041a\u0430\u043a \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c waypoint&#8217;\u044b \u0438 \u0440\u0430\u0434\u0438\u0443\u0441\u044b \u0430\u0442\u0430\u043a \u0431\u0430\u0448\u0435\u043d. <\/li>\n<\/ul>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u0443\u0440\u043e\u043a\u0430, \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u043e\u0439 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u0433\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u043d\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b \u0432\u0440\u0430\u0433\u043e\u0432, \u0431\u0430\u0448\u0435\u043d \u0438 \u043a\u0430\u0440\u0442.<br \/>  \u0414\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0440\u043e\u043a\u0430, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 Cocos2D. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u043e\u0432\u0438\u0447\u043e\u043a, \u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043b\u0435\u0433\u043a\u0438\u0435 \u0443\u0440\u043e\u043a\u0438 \u043d\u0430 <a href=\"http:\/\/www.raywenderlich.com\/tutorials#cocos2d\">\u0441\u0430\u0439\u0442\u0435 \u0420\u044d\u044f<\/a>.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h5>\u0412\u0438\u0434 \u0441 \u0411\u0430\u0448\u043d\u0438 \u0438\u0437 \u0421\u043b\u043e\u043d\u043e\u0432\u043e\u0439 \u041a\u043e\u0441\u0442\u0438 <\/h5>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u0436\u0430\u043d\u0440\u043e\u043c, Tower Defence \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0438\u0433\u0440\u0443, \u0433\u0434\u0435 \u0438\u0433\u0440\u043e\u043a \u043f\u043e\u043a\u0443\u043f\u0430\u0435\u0442 \u0438 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442 \u0432\u043e\u043e\u0440\u0443\u0436\u0435\u043d\u043d\u044b\u0435 \u0431\u0430\u0448\u043d\u0438 \u0432 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0442\u043e\u0447\u043a\u0430\u0445, \u0447\u0442\u043e\u0431\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u043e\u043b\u043d\u044b \u0432\u0440\u0430\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u044b\u0442\u0430\u044e\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0438\u0447\u044c \u0431\u0430\u0437\u044b \u0438 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0438\u0442\u044c \u0435\u0435.<br \/>  \u041a\u0430\u0436\u0434\u0430\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0432\u043e\u043b\u043d\u0430 \u0432\u0440\u0430\u0433\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439, \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0437\u0430 \u0441\u0447\u0435\u0442 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u0438 \u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u043e\u0440\u0443\u0436\u0438\u044e \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f. \u0418\u0433\u0440\u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u044b\u0441\u0442\u043e\u044f\u043b\u0438 \u0432\u0441\u0435 \u0432\u043e\u043b\u043d\u044b \u0432\u0440\u0430\u0433\u043e\u0432(\u041f\u043e\u0431\u0435\u0434\u0430!), \u043b\u0438\u0431\u043e \u0436\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u0433\u0434\u0430 \u0432\u0440\u0430\u0433\u0438 \u0434\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c \u0434\u043e \u0431\u0430\u0437\u044b \u0438 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0438\u043b\u0438 \u0435\u0435(\u041f\u0440\u043e\u0439\u0433\u0440\u044b\u0448!).<br \/>  \u0412\u043e\u0442 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442 \u0438\u0433\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0446\u0435 \u0443\u0440\u043e\u043a\u0430:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/cdn2.raywenderlich.com\/wp-content\/uploads\/2012\/06\/photo13-480x320.png\" alt=\"image\"\/><\/p>\n<p>  \u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435, \u0432\u0440\u0430\u0433\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u0437 \u043b\u0435\u0432\u043e\u0439 \u0432\u0435\u0440\u0445\u043d\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u044d\u043a\u0440\u0430\u043d\u0430 \u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0432\u0434\u043e\u043b\u044c \u0437\u0435\u043b\u0435\u043d\u043e\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043a \u0431\u0430\u0437\u0435 \u0438\u0433\u0440\u043e\u043a\u0430.<br \/>  \u0412\u0434\u043e\u043b\u044c \u0434\u043e\u0440\u043e\u0433\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c, \u0433\u0434\u0435 \u0438\u0433\u0440\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0430\u0448\u043d\u044e. \u0418\u0433\u0440\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u043a\u0443\u043f\u0438\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0448\u0435\u043d, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0437\u0430\u043f\u0430\u0441\u044b \u0437\u043e\u043b\u043e\u0442\u0430. \u0420\u0430\u0434\u0438\u0443\u0441\u044b \u0430\u0442\u0430\u043a\u0438 \u0431\u0430\u0448\u0435\u043d, \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0431\u0435\u043b\u044b\u043c \u043a\u0440\u0443\u0433\u043e\u043c, \u0435\u0441\u043b\u0438 \u0432\u0440\u0430\u0433\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u044d\u0442\u043e\u0433\u043e \u043a\u0440\u0443\u0433\u0430, \u0431\u0430\u0448\u043d\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c \u043f\u043e \u043d\u0438\u043c \u043f\u043e\u043a\u0430 \u043d\u0435 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0438\u0442, \u043b\u0438\u0431\u043e \u0432\u0440\u0430\u0433\u0438 \u043d\u0435 \u0432\u044b\u0439\u0434\u0443\u0442 \u0438\u0437 \u0440\u0430\u0434\u0438\u0443\u0441\u0430 \u0430\u0442\u0430\u043a\u0438.<\/p>\n<h5>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/h5>\n<p>  \u0414\u043b\u044f \u0432\u0430\u0441 \u0443\u0436\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d <a href=\"http:\/\/cdn2.raywenderlich.com\/downloads\/TowerDefenseStarter.zip\">\u0441\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442<\/a>, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0432 \u0441\u0435\u0431\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d Cocos2D \u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0445\u043e\u0434\u0435 \u0443\u0440\u043e\u043a\u0430.<br \/>  \u0421\u0442\u0430\u0440\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d Cocos2D 1.1, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0435 HelloWorldLayer \u0438 \u0441\u0442\u0440\u043e\u043a\u0443 \u043f\u043e \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0435 \u044d\u043a\u0440\u0430\u043d\u0430. \u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c HelloWorldLayer, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0438 \u0432\u0441\u0435 \u0436\u0435 \u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u0431\u044b\u043b\u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<br \/>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 Xcode, \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0435\u0433\u043e. \u0422\u0435\u043a\u0441\u0442 \u00abHello World\u00bb \u0443\u0434\u0430\u043b\u0435\u043d \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0447\u0435\u0440\u043d\u044b\u0439 \u044d\u043a\u0440\u0430\u043d \u0438 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043e\u043a \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430.<br \/>  \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0412\u043d\u0443\u0442\u0440\u0438 \u043f\u0430\u043f\u043a\u0438 TowerDefense \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435:  <\/p>\n<ul>\n<li> \u0412\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0432 \u0438\u0433\u0440\u0435<\/li>\n<li> \u041f\u0430\u043f\u043a\u0430 \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 Cocos2D<\/li>\n<li> \u041f\u0430\u043f\u043a\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0439 \u0438 \u0437\u0432\u0443\u043a\u0430\u043c\u0438<\/li>\n<\/ul>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0447\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0443 \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0430\u0448\u043d\u0438!<\/p>\n<h5>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0431\u0430\u0448\u0435\u043d<\/h5>\n<p>  \u0412\u043d\u0430\u0447\u0430\u043b\u0435, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0444\u043e\u043d\u043e\u0432\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u043d\u0430 \u0441\u0446\u0435\u043d\u0443. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 <b>HelloWorldLayer.m<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u043a\u043e\u0434\u0430 \u0432\u043d\u0443\u0442\u0440\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u00abif\u00bb \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u00abinit\u00bb:<\/p>\n<pre><code class=\"objectivec\">\/\/ 1 - \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f self.isTouchEnabled = YES; CGSize wins = [CCDirector sharedDirector].winSize; \/\/ 2 - \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u043e\u043d\u0430     CCSprite * background = [CCSprite spriteWithFile:@&quot;Bg.png&quot;]; [self addChild:background]; [background setPosition:ccp(wins.width\/2,wins.height\/2)]; <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 #1 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043b\u043e\u044e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043a\u0430\u0441\u0430\u043d\u0438\u044f. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 #2 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0444\u043e\u043d\u043e\u0432\u044b\u0439 \u0441\u043f\u0440\u0430\u0439\u0442 \u043d\u0430 \u043d\u0430\u0448\u0443 \u0441\u0446\u0435\u043d\u0443.<br \/>  \u0424\u043e\u043d\u043e\u0432\u0430\u044f \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0433\u0434\u0435 \u0438\u0433\u0440\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0431\u0430\u0448\u043d\u0438. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0447\u0435\u043a \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u043a\u0430\u0441\u0430\u044f\u0441\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0433\u0440\u043e\u043a \u0441\u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u0430\u0448\u043d\u0438.<br \/>  \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u043c\u044b\u0441\u043b \u043d\u0430\u0448\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u0432\u0441\u0435 \u0442\u043e\u0447\u043a\u0438 \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0444\u0430\u0439\u043b\u0435 &quot;.plist&quot;, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c. <b>TowerPosition.plist<\/b> \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043f\u0430\u043f\u043a\u0435 Resources \u0438 \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u0439 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0431\u0430\u0448\u0435\u043d \u0432\u043d\u0443\u0442\u0440\u0438.<br \/>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b, \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043a\u043b\u044e\u0447\u0430: \u00abx\u00bb \u0438 \u00aby\u00bb. \u041a\u0430\u0436\u0434\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u0431\u0430\u0448\u043d\u0438 \u043f\u043e \u0435\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0430\u0437\u044b \u0434\u043b\u044f \u0431\u0430\u0448\u0435\u043d \u043d\u0430 \u043a\u0430\u0440\u0442\u0435.<br \/>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HelloWorldLayer.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e (\u0432\u043d\u0443\u0442\u0440\u044c \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043e\u043a \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 <a href=\"http:\/\/habrahabr.ru\/users\/interface\/\" class=\"user_link\">interface<\/a>):<\/p>\n<pre><code class=\"objectivec\">NSMutableArray * towerBases; <\/code><\/pre>\n<p>  \u0412\u043d\u0435\u0441\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 <b>HelloWorldLayer.m<\/b>:<\/p>\n<pre><code class=\"objectivec\">\/\/\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0434 &quot;init&quot; -(void)loadTowerPositions {     NSString* plistPath = [[NSBundle mainBundle] pathForResource:@&quot;TowersPosition&quot; ofType:@&quot;plist&quot;];     NSArray * towerPositions = [NSArray arrayWithContentsOfFile:plistPath];     towerBases = [[NSMutableArray alloc] initWithCapacity:10];       for(NSDictionary * towerPos in towerPositions)     {         CCSprite * towerBase = [CCSprite spriteWithFile:@&quot;open_spot.png&quot;];         [self addChild:towerBase];         [towerBase setPosition:ccp([[towerPos objectForKey:@&quot;x&quot;] intValue],[[towerPos objectForKey:@&quot;y&quot;] intValue])];         [towerBases addObject:towerBase];     }   }   \/\/\u0412\u043d\u0443\u0442\u0440\u0438 init, \u0432\u044b\u0437\u043e\u0432\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0430 #2 \/\/ 3 - \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0431\u0430\u0448\u0435\u043d [self loadTowerPositions];   \/\/\u0412 dealloc, \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u0435 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (\u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c super) [towerBases release]; <\/code><\/pre>\n<p>  \u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u044b \u043f\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u043c \u0434\u043e\u0440\u043e\u0433\u0438, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0431\u0430\u0437\u043e\u0439 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0431\u0430\u0448\u0435\u043d.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/cdn1.raywenderlich.com\/wp-content\/uploads\/2012\/07\/photo16-480x320.png\" alt=\"image\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u0438 \u0431\u0430\u0437\u044b \u0433\u043e\u0442\u043e\u0432\u044b, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0448\u0435\u043d!<br \/>  \u0412\u043d\u0430\u0447\u0430\u043b\u0435, \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HelloWorldLayer.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0444\u0438\u0433\u0443\u0440\u043d\u044b\u0445 \u0441\u043a\u043e\u0431\u043e\u043a:<\/p>\n<pre><code class=\"objectivec\">@property (nonatomic,retain) NSMutableArray *towers; <\/code><\/pre>\n<p>  \u0421\u0438\u043d\u0442\u0435\u0437\u0438\u0440\u0443\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0431\u0430\u0448\u0435\u043d \u0432 <b>HelloWorldLayer.m<\/b> \u043d\u0438\u0436\u0435 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 @implementation:<\/p>\n<pre><code class=\"objectivec\">@synthesize towers; <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c, \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0431\u0430\u0448\u043d\u0438. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 iOS\\Cocoa Touch\\Objective-C. \u041d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 <b>Tower<\/b>, \u0438 \u0441\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0435\u0433\u043e \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u043c <b>CCNode<\/b>.<br \/>  \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <b>Tower.h<\/b> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c:<\/p>\n<pre><code class=\"objectivec\">#import &quot;cocos2d.h&quot; #import &quot;HelloWorldLayer.h&quot;   #define kTOWER_COST 300   @class HelloWorldLayer, Enemy;   @interface Tower: CCNode {     int attackRange;     int damage;     float fireRate; }   @property (nonatomic,assign) HelloWorldLayer *theGame; @property (nonatomic,assign) CCSprite *mySprite;   +(id)nodeWithTheGame:(HelloWorldLayer*)_game location:(CGPoint)location; -(id)initWithTheGame:(HelloWorldLayer *)_game location:(CGPoint)location;   @end <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <b>Tower.m<\/b> \u044d\u0442\u0438\u043c:<\/p>\n<pre><code class=\"objectivec\">#import &quot;Tower.h&quot;   @implementation Tower   @synthesize mySprite,theGame;   +(id) nodeWithTheGame:(HelloWorldLayer*)_game location:(CGPoint)location {     return [[[self alloc] initWithTheGame:_game location:location] autorelease]; }   -(id) initWithTheGame:(HelloWorldLayer *)_game location:(CGPoint)location { \tif( (self=[super init])) {   \t\ttheGame = _game;         \tattackRange = 70;        \t\tdamage = 10;         \tfireRate = 1;           \tmySprite = [CCSprite spriteWithFile:@&quot;tower.png&quot;]; \t\t[self addChild:mySprite];           \t[mySprite setPosition:location];           \t[theGame addChild:self];           \t[self scheduleUpdate];   \t}   \treturn self; }   -(void)update:(ccTime)dt {   }   -(void)draw {     glColor4f(255, 255, 255, 255);     ccDrawCircle(mySprite.position, attackRange, 360, 30, false);     [super draw]; }   -(void)dealloc { \t[super dealloc]; } @end <\/code><\/pre>\n<p>  \u041a\u043b\u0430\u0441\u0441 \u0431\u0430\u0448\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445: \u0441\u043f\u0440\u0430\u0439\u0442- \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0430\u0448\u043d\u0438, \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0441\u043b\u043e\u0439 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438 \u0442\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:  <\/p>\n<ul>\n<li> attackRange: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0430\u0448\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0430\u0442\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0432\u0440\u0430\u0433\u043e\u0432<\/li>\n<li> damage: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0440\u043e\u043d\u0430 \u0431\u0430\u0448\u043d\u044f \u043d\u0430\u043d\u043e\u0441\u0438\u0442 \u0432\u0440\u0430\u0433\u0430\u043c<\/li>\n<li> fireRate: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u0430\u0448\u043d\u0438 \u043d\u0430 \u043f\u0435\u0440\u0435\u0437\u0430\u0440\u044f\u0434\u043a\u0443<\/li>\n<\/ul>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u0438\u0445 \u0442\u0440\u0435\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0438\u0434\u043e\u0432 \u0431\u0430\u0448\u0435\u043d \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0430\u0442\u0430\u043a. \u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043a\u043e\u0434 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u0435\u0442\u043e\u0434 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0440\u0430\u0434\u0438\u0443\u0441\u0430 \u0430\u0442\u0430\u043a\u0438 \u0431\u0430\u0448\u043d\u0438 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<br \/>  \u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0438\u0433\u0440\u043e\u043a\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0431\u0430\u0448\u043d\u0438!<br \/>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HelloWorldLayer.m<\/b> \u0438 \u0432\u043d\u0435\u0441\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"objectivec\">\/\/\u0412 \u0432\u0435\u0440\u0445\u0443\u0448\u043a\u0435 \u0444\u0430\u0439\u043b\u0430: #import &quot;Tower.h&quot;   \/\/\u0412\u043d\u0443\u0442\u0440\u0438dealloc:  [towers release];   \/\/\u041f\u043e\u0441\u043b\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 dealloc \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b: -(BOOL)canBuyTower {     return YES; }   - (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {   \tfor( UITouch *touch in touches ) { \t\tCGPoint location = [touch locationInView: [touch view]];   \t\tlocation = [[CCDirector sharedDirector] convertToGL: location];          \t \tfor(CCSprite * tb in towerBases)         \t{ \t\t\t if([self canBuyTower] && CGRectContainsPoint([tb boundingBox],location) && !tb.userData) \t\t\t{ \t\t\t\t \/\/\u041c\u044b \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043c \u043d\u0430\u0448\u0435 \u0437\u043e\u043b\u043e\u0442\u043e \u043f\u043e\u0437\u0436\u0435.                   \t\tTower * tower = [Tower nodeWithTheGame:self location:tb.position];                 \t\t[towers addObject:tower];                \t\t\t tb.userData = tower; \t\t\t} \t\t} \t} } <\/code><\/pre>\n<p>  <b>ccTouchesBegan<\/b>: \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u0442 \u043a\u0430\u0441\u0430\u043d\u0438\u044f \u044d\u043a\u0440\u0430\u043d\u0430. \u0417\u0430\u0442\u0435\u043c \u043a\u043e\u0434 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044e \u043f\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0443 towerBases \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u0438 \u043a\u0430\u043a\u0430\u044f-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u0437 \u0431\u0430\u0437 \u0431\u0430\u0448\u0435\u043d \u0442\u043e\u0447\u043a\u0443 \u043a\u0430\u0441\u0430\u043d\u0438\u044f.<br \/>  \u041d\u043e \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u0430\u0448\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u043d\u044b, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0434\u0432\u0435 \u0432\u0435\u0449\u0438:  <\/p>\n<ol>\n<li>\u041c\u043e\u0436\u0435\u0442 \u043b\u0438 \u0438\u0433\u0440\u043e\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435? \u041c\u0435\u0442\u043e\u0434 canBuyTower \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442, \u0438\u043c\u0435\u0435\u0442 \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u043e\u043b\u043e\u0442\u0430, \u0447\u0442\u043e\u0431\u044b \u043a\u0443\u043f\u0438\u0442\u044c \u0431\u0430\u0448\u043d\u044e. \u0425\u043e\u0442\u044f, \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0443 \u0438\u0433\u0440\u043e\u043a\u0430 \u0432\u0441\u0435 \u0437\u043e\u043b\u043e\u0442\u043e \u0444\u043e\u0440\u0442\u0430 \u041d\u043e\u043a\u0441 \u0438 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0432\u0441\u0435\u0433\u0434\u0430 YES.<\/li>\n<li>\u041d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 \u043b\u0438 \u0438\u0433\u0440\u043e\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0439\u043a\u0438? \u0415\u0441\u043b\u0438 tb.UserData \u0437\u0430\u0434\u0430\u043d\u0430, \u0442\u043e\u0433\u0434\u0430 \u043d\u0430 \u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0443\u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u0431\u0430\u0448\u043d\u044f \u0438 \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e.<\/li>\n<\/ol>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b, \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0431\u0430\u0448\u043d\u044f, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0431\u0430\u0437\u0443 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0448\u0435\u043d.<br \/>  \u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0438\u0433\u0440\u0443. \u041a\u043e\u0441\u043d\u0438\u0442\u0435\u0441\u044c \u043b\u044e\u0431\u043e\u0439 \u0431\u0430\u0437\u044b, \u0438 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0430\u0448\u043d\u044f \u0441 \u0431\u0435\u043b\u044b\u043c \u043a\u0440\u0443\u0433\u043e\u043c \u0432\u043e\u043a\u0440\u0443\u0433 \u043d\u0435\u0435, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u0440\u0430\u0434\u0438\u0443\u0441 \u0435\u0435 \u0430\u0442\u0430\u043a\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/cdn3.raywenderlich.com\/wp-content\/uploads\/2012\/07\/photo17-480x320.png\" alt=\"image\"\/><br \/>  \u041d\u043e \u043a \u0447\u0435\u043c\u0443 \u0432\u0441\u0435 \u044d\u0442\u043e \u0432\u043e\u043e\u0440\u0443\u0436\u0435\u043d\u0438\u0435 \u0431\u0435\u0437 \u00ab\u043f\u043b\u043e\u0445\u0438\u0445 \u043f\u0430\u0440\u043d\u0435\u0439\u00bb, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0437\u043e\u0432\u0435\u043c \u0438\u0445 \u043d\u0430 \u0432\u0435\u0447\u0435\u0440\u0438\u043d\u043a\u0443!<\/p>\n<h5>\u041f\u043e\u043b\u0438\u0442\u0438\u043a\u0430 \u0438\u0433\u0440\u044b: \u0412\u0440\u0430\u0433\u0438, \u0412\u043e\u043b\u043d\u044b \u0438 \u0412\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u044b<\/h5>\n<p>  \u0414\u043e \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0440\u0430\u0433\u043e\u0432, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u043b\u043e\u0436\u0438\u043c \u0434\u043e\u0440\u043e\u0433\u043e \u0434\u043b\u044f \u043d\u0438\u0445. \u0412\u0440\u0430\u0433\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0443 \u0438\u0437 \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e \u0441\u0443\u0442\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0442\u043e\u0447\u043a\u0430\u043c\u0438, \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u043c\u0438 \u043f\u0443\u0442\u044c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0432\u0440\u0430\u0433\u043e\u0432 \u0432 \u0432\u0430\u0448\u0435\u043c \u043c\u0438\u0440\u0435. \u0412\u0440\u0430\u0433\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u0435, \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435, \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u043c\u0443, \u0438 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u044c\u0441\u044f, \u043f\u043e\u043a\u0430 \u043e\u043d\u0438 \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u2014 \u0432\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u044b! \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u2014 \u0432\u044b \u043f\u043e\u043d\u0435\u0441\u0435\u0442\u0435 \u0443\u0440\u043e\u043d.<br \/>  \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u043e\u0432 \u043f\u0443\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0438\u0437 iOS\\Cocoa Touch\\Objective-C \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 <b>Waypoint<\/b> \u0438 \u0441\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0435\u0433\u043e \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u043c <b>CCNode<\/b>.<br \/>  \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <b>Waypoint.h<\/b> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c:<\/p>\n<pre><code class=\"objectivec\">#import &quot;cocos2d.h&quot; #import &quot;HelloWorldLayer.h&quot;   @interface Waypoint: CCNode {     HelloWorldLayer *theGame; }   @property (nonatomic,readwrite) CGPoint myPosition; @property (nonatomic,assign) Waypoint *nextWaypoint;   +(id)nodeWithTheGame:(HelloWorldLayer*)_game location:(CGPoint)location; -(id)initWithTheGame:(HelloWorldLayer *)_game location:(CGPoint)location;   @end <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <b>Waypoint.m<\/b>:<\/p>\n<pre><code class=\"objectivec\">#import &quot;Waypoint.h&quot;   @implementation Waypoint   @synthesize myPosition, nextWaypoint;   +(id)nodeWithTheGame:(HelloWorldLayer*)_game location:(CGPoint)location {     return [[[self alloc] initWithTheGame:_game location:location] autorelease]; }   -(id)initWithTheGame:(HelloWorldLayer *)_game location:(CGPoint)location { \tif( (self=[super init])) {   \t\ttheGame = _game;           [self setPosition:CGPointZero];         myPosition = location;           [theGame addChild:self];   \t}   \treturn self; }   -(void)draw {     glColor4f(0, 255, 0, 255);     ccDrawCircle(myPosition, 6, 360, 30, false);     ccDrawCircle(myPosition, 2, 360, 30, false);       if(nextWaypoint)         ccDrawLine(myPosition, nextWaypoint.myPosition);       [super draw];    }   -(void)dealloc {     [super dealloc]; }   @end <\/code><\/pre>\n<p>  \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043a\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u0430, \u0441\u0441\u044b\u043b\u0430\u044f\u0441\u044c \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 HelloWorldLayer \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044f CGPoint, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439 \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u0430.<br \/>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439, \u044d\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u043e\u0432. \u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442 \u00ab\u0437\u043d\u0430\u0435\u0442\u00bb \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432 \u0441\u043f\u0438\u0441\u043a\u0435.\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0435\u0441\u0442\u0438 \u0432\u0440\u0430\u0433\u043e\u0432 \u043a \u0438\u0445 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0446\u0435\u043b\u0438, \u043f\u0440\u043e\u0434\u0432\u0438\u0433\u0430\u044f\u0441\u044c \u043f\u043e \u0446\u0435\u043f\u043e\u0447\u043a\u0435 \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u043e\u0432.<br \/>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u0435\u0442\u043e\u0434 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u043c, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u044b, \u0438 \u0440\u0438\u0441\u0443\u0435\u0442 \u043b\u0438\u043d\u0438\u044e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438, \u0432 \u0446\u0435\u043b\u044f\u0445 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. <br \/>  \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u043e\u0432. \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HelloWorldLayer.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e:<\/p>\n<pre><code class=\"objectivec\">@property (nonatomic,retain) NSMutableArray *waypoints; <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0432 <b>HelloWorldLayer.m<\/b>:<\/p>\n<pre><code class=\"objectivec\">\/\/\u0412 \u0441\u0430\u043c\u043e\u043c \u0432\u0435\u0440\u0445\u0443 \u0444\u0430\u0439\u043b\u0430: #import &quot;Waypoint.h&quot;   \/\/ \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 synthesise @synthesize waypoints;   \/\/\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0434 init -(void)addWaypoints {     waypoints = [[NSMutableArray alloc] init];       Waypoint * waypoint1 = [Waypoint nodeWithTheGame:self location:ccp(420,35)];     [waypoints addObject:waypoint1];       Waypoint * waypoint2 = [Waypoint nodeWithTheGame:self location:ccp(35,35)];     [waypoints addObject:waypoint2];     waypoint2.nextWaypoint =waypoint1;       Waypoint * waypoint3 = [Waypoint nodeWithTheGame:self location:ccp(35,130)];     [waypoints addObject:waypoint3];     waypoint3.nextWaypoint =waypoint2;       Waypoint * waypoint4 = [Waypoint nodeWithTheGame:self location:ccp(445,130)];     [waypoints addObject:waypoint4];     waypoint4.nextWaypoint =waypoint3;       Waypoint * waypoint5 = [Waypoint nodeWithTheGame:self location:ccp(445,220)];     [waypoints addObject:waypoint5];      waypoint5.nextWaypoint =waypoint4;       Waypoint * waypoint6 = [Waypoint nodeWithTheGame:self location:ccp(-40,220)];     [waypoints addObject:waypoint6];      waypoint6.nextWaypoint =waypoint5;   }   \/\/ \u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 init: \/\/ 4 - Add waypoints [self addWaypoints];   \/\/\u0412\u043d\u0443\u0442\u0440\u0438 dealloc [waypoints release]; <\/code><\/pre>\n<p>  \u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0438\u0433\u0440\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/cdn4.raywenderlich.com\/wp-content\/uploads\/2012\/07\/photo18-480x320.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0430 \u043a\u0430\u0440\u0442\u0435 \u0448\u0435\u0441\u0442\u044c \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u043e\u0432, \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u0432\u0440\u0430\u0433\u0438. \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u0432\u044b \u0434\u0430\u0434\u0438\u0442\u0435 \u0434\u0440\u0443\u0437\u044c\u044f\u043c \u043f\u0440\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u0432 \u0438\u0433\u0440\u0435, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0447\u0442\u043e\u0431\u044b \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043c\u043e\u0433\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439 \u043e\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430.<br \/>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HelloWorldLayer.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0435\u0440\u0435\u0434 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439 &quot;<a href=\"http:\/\/habrahabr.ru\/users\/end\/\" class=\"user_link\">end<\/a>&quot;:<\/p>\n<pre><code class=\"objectivec\">-(BOOL)circle:(CGPoint)circlePoint withRadius:(float)radius collisionWithCircle:(CGPoint)circlePointTwo collisionCircleRadius:(float)radiusTwo; void ccFillPoly(CGPoint *poli, int points, BOOL closePolygon); <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HelloWorldLayer.m<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430 (\u043f\u0435\u0440\u0435\u0434 <a href=\"http:\/\/habrahabr.ru\/users\/end\/\" class=\"user_link\">end<\/a>):<\/p>\n<pre><code class=\"objectivec\">void ccFillPoly( CGPoint *poli, int points, BOOL closePolygon ) {     \/\/ \u041e\u0431\u044b\u0447\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f GL: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY     \/\/ \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f: GL_VERTEX_ARRAY,     \/\/ \u041d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY     glDisable(GL_TEXTURE_2D);     glDisableClientState(GL_TEXTURE_COORD_ARRAY);     glDisableClientState(GL_COLOR_ARRAY);       glVertexPointer(2, GL_FLOAT, 0, poli);     if( closePolygon )         glDrawArrays(GL_TRIANGLE_FAN, 0, points);     else         glDrawArrays(GL_LINE_STRIP, 0, points);       \/\/ restore default state     glEnableClientState(GL_COLOR_ARRAY);     glEnableClientState(GL_TEXTURE_COORD_ARRAY);     glEnable(GL_TEXTURE_2D); }   -(BOOL)circle:(CGPoint) circlePoint withRadius:(float) radius collisionWithCircle:(CGPoint) circlePointTwo collisionCircleRadius:(float) radiusTwo {     float xdif = circlePoint.x - circlePointTwo.x;     float ydif = circlePoint.y - circlePointTwo.y;       float distance = sqrt(xdif*xdif+ydif*ydif);       if(distance &lt;= radius+radiusTwo)          return YES;       return NO; } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 collisionWithCircle \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043c \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0434\u0432\u0430 \u043a\u0440\u0443\u0433\u0430 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f. \u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u0434\u043e\u0441\u0442\u0438\u0433 \u043b\u0438 \u0432\u0440\u0430\u0433 \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u044f\u0432\u0438\u0442\u044c \u0432\u0440\u0430\u0433\u043e\u0432, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u0432 \u0440\u0430\u0434\u0438\u0443\u0441\u0435 \u0430\u0442\u0430\u043a\u0438 \u0431\u0430\u0448\u043d\u0438.<br \/>  \u041c\u0435\u0442\u043e\u0434 ccFillPoly \u0440\u0438\u0441\u0443\u0435\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e OpenGL. \u0412 Cocos2d \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u044b. \u041c\u0435\u0442\u043e\u0434 ccFillPoly \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0440\u0438\u0441\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u043e\u0441\u043e\u043a \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u044f \u0432\u0440\u0430\u0433\u043e\u0432.<br \/>  \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0440\u0430\u0433\u043e\u0432.<br \/>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HelloWorldLayer.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"objectivec\">\/\/ \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u044d\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 int wave; CCLabelBMFont *ui_wave_lbl;   \/\/ \u0422\u0430\u043c \u0433\u0434\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f property @property (nonatomic,retain) NSMutableArray *enemies; <\/code><\/pre>\n<p>  \u0412\u043d\u0435\u0441\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 <b>HelloWorldLayer.m<\/b>:<\/p>\n<pre><code class=\"objectivec\">\/\/ Synthesize enemies @synthesize enemies;   \/\/ \u0412 dealloc [enemies release]; <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0440\u0430\u0433\u0430\u0445 \u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u044d\u043a\u0440\u0430\u043d\u0443. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b iOS\\Cocoa Touch\\Objective-C. \u041d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 <b>Enemy<\/b> \u0438 \u0441\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0435\u0433\u043e \u043f\u043e\u0434\u043a\u043b\u0430\u0441\u0441\u043e\u043c <b>CCNode<\/b>.<br \/>  \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <b>Enemy.h<\/b>:<\/p>\n<pre><code class=\"objectivec\">#import &quot;cocos2d.h&quot; #import &quot;HelloWorldLayer.h&quot; #import &quot;GameConfig.h&quot;   @class HelloWorldLayer, Waypoint, Tower;   @interface Enemy: CCNode {     CGPoint myPosition;     int maxHp;     int currentHp;     float walkingSpeed;     Waypoint *destinationWaypoint;     BOOL active; }   @property (nonatomic,assign) HelloWorldLayer *theGame; @property (nonatomic,assign) CCSprite *mySprite;   +(id)nodeWithTheGame:(HelloWorldLayer*)_game; -(id)initWithTheGame:(HelloWorldLayer *)_game; -(void)doActivate; -(void)getRemoved;   @end <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 <b>Enemy.m<\/b>:<\/p>\n<pre><code class=\"objectivec\">#import &quot;Enemy.h&quot; #import &quot;Tower.h&quot; #import &quot;Waypoint.h&quot; #import &quot;SimpleAudioEngine.h&quot;   #define HEALTH_BAR_WIDTH 20 #define HEALTH_BAR_ORIGIN -10   @implementation Enemy   @synthesize mySprite, theGame;   +(id)nodeWithTheGame:(HelloWorldLayer*)_game {     return [[[self alloc] initWithTheGame:_game] autorelease]; }   -(id)initWithTheGame:(HelloWorldLayer *)_game { \tif ((self=[super init])) {   \t\ttheGame = _game;         maxHp = 40;         currentHp = maxHp;           active = NO;           walkingSpeed = 0.5;           mySprite = [CCSprite spriteWithFile:@&quot;enemy.png&quot;]; \t\t[self addChild:mySprite];           Waypoint * waypoint = (Waypoint *)[theGame.waypoints objectAtIndex:([theGame.waypoints count]-1)];           destinationWaypoint = waypoint.nextWaypoint;           CGPoint pos = waypoint.myPosition;         myPosition = pos;           [mySprite setPosition:pos];           [theGame addChild:self];           [self scheduleUpdate];   \t}   \treturn self; }   -(void)doActivate {     active = YES; }   -(void)update:(ccTime)dt {     if(!active)return;       if([theGame circle:myPosition withRadius:1 collisionWithCircle:destinationWaypoint.myPosition collisionCircleRadius:1])     {         if(destinationWaypoint.nextWaypoint)         {             destinationWaypoint = destinationWaypoint.nextWaypoint;         }else         {             \/\/\u0414\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442 \u043a\u043e\u043d\u0435\u0446 \u043f\u0443\u0442\u0438. \u041d\u0430\u043d\u0435\u0441\u0435\u043d\u0438\u0435 \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439 \u0438\u0433\u0440\u043e\u043a\u0443             [theGame getHpDamage];             [self getRemoved];         }     }       CGPoint targetPoint = destinationWaypoint.myPosition;     float movementSpeed = walkingSpeed;       CGPoint normalized = ccpNormalize(ccp(targetPoint.x-myPosition.x,targetPoint.y-myPosition.y));     mySprite.rotation = CC_RADIANS_TO_DEGREES(atan2(normalized.y,-normalized.x));       myPosition = ccp(myPosition.x+normalized.x * movementSpeed,myPosition.y+normalized.y * movementSpeed);      [mySprite setPosition:myPosition];     }   -(void)getRemoved {     [self.parent removeChild:self cleanup:YES];     [theGame.enemies removeObject:self];       \/\/\u0421\u043e\u043e\u0431\u0449\u0438\u0442\u0435 \u0438\u0433\u0440\u0435 \u0447\u0442\u043e \u043c\u044b \u0443\u0431\u0438\u043b\u0438 \u0432\u0440\u0430\u0433\u0430 \u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0432\u043e\u043b\u043d\u0443     [theGame enemyGotKilled]; }   -(void)draw {     glColor4f(255, 0, 0, 255);     CGPoint healthBarBack[] = {ccp(mySprite.position.x -10,mySprite.position.y+16),ccp(mySprite.position.x+10,mySprite.position.y+16),ccp(mySprite.position.x+10,mySprite.position.y+14),ccp(mySprite.position.x-10,mySprite.position.y+14)};     ccFillPoly(healthBarBack, 4, YES);       glColor4f(0, 255, 0, 255);     CGPoint healthBar[] = {ccp(mySprite.position.x + HEALTH_BAR_ORIGIN,mySprite.position.y+16),ccp(mySprite.position.x+HEALTH_BAR_ORIGIN+(float)(currentHp * HEALTH_BAR_WIDTH) \/ maxHp,mySprite.position.y+16),ccp(mySprite.position.x+HEALTH_BAR_ORIGIN+(float)(currentHp * HEALTH_BAR_WIDTH) \/ maxHp,mySprite.position.y+14),ccp(mySprite.position.x+HEALTH_BAR_ORIGIN,mySprite.position.y+14)};     ccFillPoly(healthBar, 4, YES); }   -(void)dealloc { \t[super dealloc]; }   @end <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0432\u043d\u0443\u0448\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0440\u0435\u0437\u043e\u043a \u043a\u043e\u0434\u0430, \u043d\u043e \u0435\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u043d\u044f\u0442\u044c. \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u0440\u0430\u0433, \u043a\u043e\u0433\u0434\u0430 HelloWorldLayer \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043d\u0435\u0433\u043e. \u0412\u043d\u0443\u0442\u0440\u0438 init \u043c\u0435\u0442\u043e\u0434\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0436\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445:  <\/p>\n<ul>\n<li>maxHP: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0434\u0430\u0440\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u0440\u0430\u0433<\/li>\n<li>walkingSpeed: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0432\u0440\u0430\u0433<\/li>\n<li>mySprite: \u0445\u0440\u0430\u043d\u0438\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0440\u0430\u0433\u0430(\u0441\u043f\u0440\u0430\u0439\u0442)<\/li>\n<li>destinationWaypoint: \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u044d\u0439\u043f\u043e\u0438\u043d\u0442<\/li>\n<\/ul>\n<p>  \u041c\u0435\u0442\u043e\u0434 update \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0430\u0434\u0440, \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0434\u043e\u0441\u0442\u0438\u0433 \u043b\u0438 \u0432\u0440\u0430\u0433 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0435\u0442\u043e\u0434 collisionWithCircle, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0438 \u0442\u0430\u043a \u043f\u043e\u043a\u0430 \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u0430, \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u043d\u043e\u0441\u0438\u043c \u0438\u0433\u0440\u043e\u043a\u0443 \u043f\u043e\u0432\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f.<br \/>  \u041f\u0435\u0440\u0435\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0435 \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0432\u0434\u043e\u043b\u044c \u043f\u0440\u044f\u043c\u043e\u0439 \u043b\u0438\u043d\u0438\u0438 \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0432\u044d\u0439\u043f\u043e\u0438\u043d\u0442\u0430 \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f, \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c:  <\/p>\n<ul>\n<li>\u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440, \u043f\u0440\u043e\u043b\u0435\u0433\u0430\u044e\u0449\u0438\u0439 \u043e\u0442 \u043d\u044b\u043d\u0435\u0448\u043d\u0435\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043a \u0446\u0435\u043b\u0435\u0432\u043e\u0439, \u0435\u043c\u0443 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 1, \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0440\u0430\u0431\u043e\u0442\u044b(\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f). <\/li>\n<li>\u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f, \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0443\u0442\u0438 \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u043d\u0438\u044f \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u043a\u0430\u0434\u0440\u0435. \u0415\u043c\u0443 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u044b\u043d\u0435\u0448\u043d\u044f\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439. <\/li>\n<\/ul>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u043c\u0435\u0442\u043e\u0434 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u043e\u043b\u043e\u0441\u043a\u0443 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u044f \u043d\u0430\u0434 \u0441\u043f\u0440\u0430\u0439\u0442\u043e\u043c. \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043e\u043d \u0440\u0438\u0441\u0443\u0435\u0442 \u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0444\u043e\u043d, \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0437\u0435\u043b\u0435\u043d\u044b\u043c, \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043d\u044b\u043d\u0435\u0448\u043d\u0435\u043c\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 HP \u0432\u0440\u0430\u0433\u0430.<br \/>  \u041a\u043b\u0430\u0441\u0441 \u0432\u0440\u0430\u0433\u043e\u0432 \u0433\u043e\u0442\u043e\u0432, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u0445 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435!<br \/>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HelloWorldLayer.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"objectivec\">-(void)enemyGotKilled; <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u0441\u044c \u043d\u0430 <b>HelloWorldLayer.m<\/b> \u0438 \u043e\u043f\u0438\u0448\u0438\u0442\u0435 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<pre><code class=\"objectivec\">\/\/\u0412\u0432\u0435\u0440\u0445\u0443 \u0444\u0430\u0439\u043b\u0430: #import &quot;Enemy.h&quot;   \/\/\u0434\u043e \u043c\u0435\u0442\u043e\u0434\u0430 init: -(BOOL)loadWave {     NSString* plistPath = [[NSBundle mainBundle] pathForResource:@&quot;Waves&quot; ofType:@&quot;plist&quot;];     NSArray * waveData = [NSArray arrayWithContentsOfFile:plistPath];       if(wave &gt;= [waveData count])     {         return NO;     }       NSArray * currentWaveData =[NSArray arrayWithArray:[waveData objectAtIndex:wave]];       for(NSDictionary * enemyData in currentWaveData)     {         Enemy * enemy = [Enemy nodeWithTheGame:self];         [enemies addObject:enemy];         [enemy schedule:@selector(doActivate) interval:[[enemyData objectForKey:@&quot;spawnTime&quot;]floatValue]];     }       wave++;     [ui_wave_lbl setString:[NSString stringWithFormat:@&quot;WAVE: %d&quot;,wave]];       return YES;   }   -(void)enemyGotKilled {     if ([enemies count]&lt;=0) \/\/If there are no more enemies.     {         if(![self loadWave])         {             NSLog(@&quot;You win!&quot;);             [[CCDirector sharedDirector] replaceScene:[CCTransitionSplitCols transitionWithDuration:1 scene:[HelloWorldLayer scene]]];         }     } }   \/\/ \u0432\u043a\u043e\u043d\u0446\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 init: \/\/ 5 - \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u0440\u0430\u0433\u043e\u0432 enemies = [[NSMutableArray alloc] init]; [self loadWave]; \/\/ 6 - \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0434\u043f\u0438\u0441\u044c \u043f\u0440\u043e \u043d\u043e\u043c\u0435\u0440 \u0432\u043e\u043b\u043d\u044b ui_wave_lbl = [CCLabelBMFont labelWithString:[NSString stringWithFormat:@&quot;WAVE: %d&quot;,wave] fntFile:@&quot;font_red_14.fnt&quot;]; [self addChild:ui_wave_lbl z:10]; [ui_wave_lbl setPosition:ccp(400,wins.height-12)]; [ui_wave_lbl setAnchorPoint:ccp(0,0.5)]; <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u0432\u044b\u0448\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0434\u043e\u0441\u0442\u043e\u0439\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f. \u0421\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c- \u043c\u0435\u0442\u043e\u0434 LoadWave; \u043e\u043d \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 <b>Waves.plist<\/b>.<br \/>  \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 <b>Waves.plist<\/b>, \u0438 \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 3 \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u041a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u043e\u043b\u043d\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u0440\u0443\u043f\u043f\u043e\u0439 \u0432\u0440\u0430\u0433\u043e\u0432, \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435. \u041f\u0435\u0440\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0448\u0435\u0441\u0442\u044c \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439. \u041a\u0430\u0436\u0434\u044b\u0439 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0432\u0440\u0430\u0433\u0430. \u0412 \u044d\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435, \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0445\u0440\u0430\u043d\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0440\u0430\u0433\u0430, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u0435 \u0442\u0438\u043f \u0432\u0440\u0430\u0433\u0430, \u0435\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u0435 \u0438 \u0442.\u0434.<br \/>  \u041c\u0435\u0442\u043e\u0434 loadWave \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0434\u043e\u043b\u0436\u043d\u0430 \u043b\u0438 \u043f\u043e\u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0432\u043e\u043b\u043d\u0430, \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0432\u0440\u0430\u0433\u043e\u0432, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0432\u043e\u043b\u043d\u0435, \u0438 \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<br \/>  \u041c\u0435\u0442\u043e\u0434 enemyGotKilled \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0440\u0430\u0433\u043e\u0432 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u0435\u0441\u043b\u0438 \u0438\u0445 \u043d\u0435\u0442, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0432\u043e\u043b\u043d\u0443. \u041f\u043e\u0437\u0436\u0435 \u044d\u0442\u043e\u0442 \u0436\u0435 \u043c\u0435\u0442\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u043e\u0431\u0435\u0434\u044b \u0438\u0433\u0440\u043e\u043a\u0430.<br \/>  \u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0438\u0433\u0440\u0443 \u0441\u0435\u0439\u0447\u0430\u0441. \u0412\u0440\u0430\u0433\u0438 \u0434\u0432\u0438\u0433\u0430\u044e\u0442\u0441\u044f \u043a \u0432\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435!<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/cdn1.raywenderlich.com\/wp-content\/uploads\/2012\/07\/photo19-480x320.png\" alt=\"image\"\/><\/p>\n<h5>\u0410\u0442\u0430\u043a\u0430 \u0431\u0430\u0448\u0435\u043d<\/h5>\n<p>  \u0411\u0430\u0448\u043d\u0438 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435? \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435. \u0412\u0440\u0430\u0433\u0438 \u0434\u0432\u0438\u0433\u0430\u044e\u0442\u0441\u044f? \u041f\u0435\u0440\u0435\u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435! \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0432\u0430\u043b\u0438\u0442\u044c \u044d\u0442\u0438\u0445 \u043d\u0430\u0433\u043b\u0435\u0446\u043e\u0432.<br \/>  \u041a\u0430\u0436\u0434\u0430\u044f \u0431\u0430\u0448\u043d\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0435\u0441\u0442\u044c \u043b\u0438 \u0432\u0440\u0430\u0433 \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u0430\u0434\u0438\u0443\u0441\u0430 \u0435\u0435 \u043f\u043e\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0434\u0430, \u0431\u0430\u0448\u043d\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c \u043f\u043e \u043d\u0435\u043c\u0443, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 \u043e\u0434\u043d\u043e \u0438\u0437 \u0434\u0432\u0443\u0445: \u0432\u0440\u0430\u0433 \u0432\u044b\u0439\u0434\u0435\u0442 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u0434\u043e\u0441\u044f\u0433\u0430\u0435\u043c\u043e\u0441\u0442\u0438, \u0438\u043b\u0438 \u0432\u0440\u0430\u0433 \u0431\u0443\u0434\u0435\u0442 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d. \u0422\u043e\u0433\u0434\u0430 \u0431\u0430\u0448\u043d\u044f \u043d\u0430\u0447\u043d\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0436\u0435\u0440\u0442\u0432\u0443.<br \/>  \u041d\u0430\u0447\u043d\u0435\u043c \u0437\u0430\u0449\u0438\u0449\u0430\u0442\u044c \u0431\u0430\u0437\u0443!<br \/>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>Tower.h<\/b> \u0438 \u0432\u043d\u0435\u0441\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"objectivec\">\/\/ \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 BOOL attacking; Enemy *chosenEnemy;   \/\/ \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 -(void)targetKilled; <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432 <b>Tower.m<\/b>:<\/p>\n<pre><code class=\"objectivec\">\/\/ \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0445\u044d\u0434\u0435\u0440 Enemy \u043a\u043b\u0430\u0441\u0441\u0430 #import &quot;Enemy.h&quot;   \/\/ \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435  \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0430\u0434 init: -(void)attackEnemy {     [self schedule:@selector(shootWeapon) interval:fireRate]; }   -(void)chosenEnemyForAttack:(Enemy *)enemy {     chosenEnemy = nil;     chosenEnemy = enemy;     [self attackEnemy];     [enemy getAttacked:self]; }   -(void)shootWeapon {     CCSprite * bullet = [CCSprite spriteWithFile:@&quot;bullet.png&quot;];     [theGame addChild:bullet];     [bullet setPosition:mySprite.position];     [bullet runAction:[CCSequence actions:[CCMoveTo actionWithDuration:0.1 position:chosenEnemy.mySprite.position],[CCCallFunc actionWithTarget:self selector:@selector(damageEnemy)],[CCCallFuncN actionWithTarget:self selector:@selector(removeBullet:)], nil]];     }   -(void)removeBullet:(CCSprite *)bullet {     [bullet.parent removeChild:bullet cleanup:YES]; }   -(void)damageEnemy {     [chosenEnemy getDamaged:damage]; }   -(void)targetKilled {     if(chosenEnemy)         chosenEnemy =nil;       [self unschedule:@selector(shootWeapon)]; }   -(void)lostSightOfEnemy {     [chosenEnemy gotLostSight:self];     if(chosenEnemy)         chosenEnemy =nil;        [self unschedule:@selector(shootWeapon)]; } <\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 update \u043d\u0430:<\/p>\n<pre><code class=\"objectivec\">-(void)update:(ccTime)dt {     if (chosenEnemy){           \/\/\u041c\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0435 \u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u043a \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c\u0443 \u0432\u0440\u0430\u0433\u0443         CGPoint normalized = ccpNormalize(ccp(chosenEnemy.mySprite.position.x-mySprite.position.x,chosenEnemy.mySprite.position.y-mySprite.position.y));         mySprite.rotation = CC_RADIANS_TO_DEGREES(atan2(normalized.y,-normalized.x))+90;           if(![theGame circle:mySprite.position withRadius:attackRange collisionWithCircle:chosenEnemy.mySprite.position collisionCircleRadius:1])         {             [self lostSightOfEnemy];         }     } else {         for(Enemy * enemy in theGame.enemies)         {             if([theGame circle:mySprite.position withRadius:attackRange collisionWithCircle:enemy.mySprite.position collisionCircleRadius:1])             {                 [self chosenEnemyForAttack:enemy];                 break;             }         }     } } <\/code><\/pre>\n<p>  \u041a\u043e\u0434\u0430 \u043c\u043d\u043e\u0433\u043e- \u044d\u0442\u043e \u0442\u0430\u043a. \u041f\u043b\u044e\u0441, \u0432\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439 \u043e\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u0430 \u043f\u043e \u043c\u0435\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0441 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f\u043c\u0438, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u044e\u0449\u0438\u0445 \u0431\u0438\u0442.<br \/>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>Enemy.h<\/b> \u0438 \u0432\u043d\u0435\u0441\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"objectivec\">\/\/\u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e NSMutableArray *attackedBy;   \/\/ \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 -(void)getAttacked:(Tower *)attacker; -(void)gotLostSight:(Tower *)attacker; -(void)getDamaged:(int)damage; <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432 <b>Enemy.m<\/b>:<\/p>\n<pre><code class=\"nginx\">\/\/\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u043c\u0435\u0442\u043e\u0434\u0430 initWithTheGame: (\u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f &quot;if&quot;) attackedBy = [[NSMutableArray alloc] initWithCapacity:5];   \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435  getRemoved: -(void)getRemoved {     for(Tower * attacker in attackedBy)     {         [attacker targetKilled];     }       [self.parent removeChild:self cleanup:YES];     [theGame.enemies removeObject:self];       \/\/\u0421\u043e\u043e\u0431\u0449\u0438\u0442\u0435 \u0438\u0433\u0440\u0435, \u0447\u0442\u043e \u043c\u044b \u0443\u0431\u0438\u043b\u0438 \u0432\u0440\u0430\u0433\u0430 \u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043d\u0443\u0436\u043d\u043e \u043b\u0438 \u0432\u044b\u0441\u043b\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0432\u043e\u043b\u043d\u0443     [theGame enemyGotKilled]; }   \/\/ \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430 -(void)getAttacked:(Tower *)attacker {     [attackedBy addObject:attacker]; }   -(void)gotLostSight:(Tower *)attacker {     [attackedBy removeObject:attacker]; }   -(void)getDamaged:(int)damage {     currentHp -=damage;     if(currentHp &lt;=0)     {         [self getRemoved];     } } <\/code><\/pre>\n<p>  \u0421\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432 \u043a\u043e\u0434\u0435- \u043c\u0435\u0442\u043e\u0434 update \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Tower. \u0411\u0430\u0448\u043d\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432\u0440\u0430\u0433\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u0430\u0434\u0438\u0443\u0441\u0430 \u0430\u0442\u0430\u043a\u0438. \u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0432\u043e\u0439 \u0438\u043c\u0435\u0435\u0442\u0441\u044f, \u0431\u0430\u0448\u043d\u044f \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a \u043d\u0435\u043c\u0443 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c.<br \/>  \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0430\u0433 \u043f\u043e\u043c\u0435\u0447\u0435\u043d, \u043a\u0430\u043a \u0446\u0435\u043b\u044c, \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u0434\u0430\u0435\u0442 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u0435\u043b\u044c\u0431\u044b \u0431\u0430\u0448\u043d\u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0435\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0440\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041a\u0430\u0436\u0434\u044b\u0439 \u0432\u0440\u0430\u0433 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u0430\u0448\u0435\u043d, \u0441\u0442\u0440\u0435\u043b\u044f\u044e\u0449\u0438\u0445 \u043f\u043e \u043d\u0435\u043c\u0443, \u0435\u0441\u043b\u0438 \u0432\u0440\u0430\u0433 \u0443\u043c\u0440\u0435\u0442, \u043e\u043d\u0438 \u0432\u0441\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u043e\u0432\u0435\u0449\u0435\u043d\u044b \u043e\u0431 \u044d\u0442\u043e\u043c \u0444\u0430\u043a\u0442\u0435 \u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0443\u0442 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c.<br \/>  \u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0432\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0420\u0430\u0441\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0448\u0435\u043d \u043d\u0430 \u043a\u0430\u0440\u0442\u0435. \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u043a\u0430\u043a \u0431\u0430\u0448\u043d\u0438 \u043d\u0430\u0447\u043d\u0443\u0442 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c \u0432\u043e \u0432\u0440\u0430\u0433\u043e\u0432, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432\u043d\u0443\u0442\u0440\u0438 \u0438\u0445 \u0440\u0430\u0434\u0438\u0443\u0441\u0430, \u043a\u0430\u043a \u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u043e\u0441\u043a\u0438 \u0438\u0445 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u044f \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043e\u043d\u0438 \u043d\u0435 \u0443\u043c\u0438\u0440\u0430\u044e\u0442.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/cdn2.raywenderlich.com\/wp-content\/uploads\/2012\/07\/photo20-480x320.png\" alt=\"image\"\/><\/p>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0442\u0430\u043b\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e tower defense. \u041d\u0435\u043f\u043b\u043e\u0445\u043e \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u0432\u0443\u043a\u043e\u0432\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b, \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u0431\u0430\u0437\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0443\u0440\u043e\u043d \u043e\u0442 \u0432\u0440\u0430\u0433\u043e\u0432 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u043e\u043b\u043e\u0442\u0430 \u0438\u0433\u0440\u043e\u043a\u0430.<\/p>\n<h5>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0448\u0442\u0440\u0438\u0445\u0438<\/h5>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0436\u0438\u0437\u043d\u0435\u0439, \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u0443 \u0438\u0433\u0440\u043e\u043a\u0430, \u0438 \u0442\u0435\u043c, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0430\u0442\u0441\u044f!<br \/>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HelloWorldLayer.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"objectivec\">int playerHp; CCLabelBMFont *ui_hp_lbl; BOOL gameEnded; <\/code><\/pre>\n<p>  playerHp \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0436\u0438\u0437\u043d\u0435\u0439 \u0443 \u0438\u0433\u0440\u043e\u043a\u0430, \u0430 CCLabelBMFont \u044d\u0442\u043e \u043d\u0430\u0434\u043f\u0438\u0441\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e. gameEnded \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0438\u0433\u0440\u0430 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430! \u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432:<\/p>\n<pre><code class=\"objectivec\">-(void)getHpDamage; -(void)doGameOver; <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HelloWorldLayer.m<\/b> \u0438 \u0432\u043d\u0435\u0441\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"objectivec\">\/\/ \u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 init: \/\/ 7 - \u0436\u0438\u0437\u043d\u0438 \u0438\u0433\u0440\u043e\u043a\u0430 playerHp = 5; ui_hp_lbl = [CCLabelBMFont labelWithString:[NSString stringWithFormat:@&quot;HP: %d&quot;,playerHp] fntFile:@&quot;font_red_14.fnt&quot;]; [self addChild:ui_hp_lbl z:10]; [ui_hp_lbl setPosition:ccp(35,wins.height-12)];   \/\/ \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u043a\u043e\u043d\u0435\u0446 \u0444\u0430\u0439\u043b\u0430: -(void)getHpDamage {     playerHp--;     [ui_hp_lbl setString:[NSString stringWithFormat:@&quot;HP: %d&quot;,playerHp]];     if (playerHp &lt;=0) {         [self doGameOver];     } }   -(void)doGameOver {     if (!gameEnded) {         gameEnded = YES;         [[CCDirector sharedDirector] replaceScene:[CCTransitionRotoZoom transitionWithDuration:1 scene:[HelloWorldLayer scene]]];     } } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0436\u0438\u0437\u043d\u0435\u0439 \u0438\u0433\u0440\u043e\u043a\u0430, \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u0434\u043f\u0438\u0441\u044c \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438\u0441\u044c \u043b\u0438 \u0436\u0438\u0437\u043d\u0438 \u0443 \u0438\u0433\u0440\u043e\u043a\u0430. \u0415\u0441\u043b\u0438 \u0434\u0430, \u0438\u0433\u0440\u0435 \u043a\u043e\u043d\u0435\u0446!<br \/>  \u041c\u0435\u0442\u043e\u0434 getHpDamage \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432\u0440\u0430\u0433 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 \u0431\u0430\u0437\u044b. \u0412\u044b \u0440\u0430\u043d\u0435\u0435 \u0443\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0435\u0433\u043e \u0432 <b>update <\/b>\u043c\u0435\u0442\u043e\u0434 \u0432 <b>Enemy.m<\/b>.<br \/>  \u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0439\u0442\u0435 \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0438\u0433\u0440\u0443. \u041f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u0432\u0440\u0430\u0433\u0430\u043c \u0434\u043e\u0439\u0442\u0438 \u0434\u043e \u0432\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u044b. \u0412\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u0448\u0438\u0445 \u0436\u0438\u0437\u043d\u0435\u0439 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u043a\u0430 \u0438\u0433\u0440\u0430 \u043d\u0435 \u043e\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/cdn1.raywenderlich.com\/wp-content\/uploads\/2012\/07\/photo21-480x320.png\" alt=\"image\"\/><\/p>\n<p>  \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0443\u0440\u0435\u0437\u0430\u0442\u044c \u0431\u044e\u0434\u0436\u0435\u0442!<br \/>  \u041c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u0433\u0440 \u0432\u043d\u0435\u0434\u0440\u044f\u044e\u0442 \u043e\u043f\u0446\u0438\u044e \u201czero-sum\u201d, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0438\u0433\u0440\u043e\u043a\u0443 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u043d\u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u0433\u0440\u044b. \u0412\u0430\u0448\u0430 \u0438\u0433\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435, \u043d\u043e \u0432 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435.<br \/>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HelloWorldLayer.h<\/b> \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"objectivec\">int playerGold; CCLabelBMFont *ui_gold_lbl; <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u0441 \u0436\u0438\u0437\u043d\u044f\u043c\u0438, \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u043e\u043b\u043e\u0442\u0430(playerGold) \u0438 \u043d\u0430\u0434\u043f\u0438\u0441\u044c \u0434\u043b\u044f \u0435\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f(ui_gold_lbl). \u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430:<\/p>\n<pre><code class=\"objectivec\">-(void)awardGold:(int)gold; <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HelloWorldLayer.m<\/b> \u0438 \u0441\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"objectivec\">\/\/\u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 \u043f\u0435\u0440\u0435\u0434 init: -(void)awardGold:(int)gold {     playerGold += gold;     [ui_gold_lbl setString:[NSString stringWithFormat:@&quot;GOLD: %d&quot;,playerGold]]; }   \/\/ \u0412 \u043a\u043e\u043d\u0446\u0435 init: \/\/ 8 - \u0417\u043e\u043b\u043e\u0442\u043e playerGold = 1000;         ui_gold_lbl = [CCLabelBMFont labelWithString:[NSString stringWithFormat:@&quot;GOLD: %d&quot;,playerGold] fntFile:@&quot;font_red_14.fnt&quot;]; [self addChild:ui_gold_lbl z:10]; [ui_gold_lbl setPosition:ccp(135,wins.height-12)]; [ui_gold_lbl setAnchorPoint:ccp(0,0.5)];   \/\/\u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 canBuyTower: -(BOOL)canBuyTower {     if (playerGold - kTOWER_COST &gt;=0)         return YES;     return NO; }   \/\/ \u0412\u043d\u0443\u0442\u0440\u0438 ccTouchesBegan, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u044f &quot;if&quot;, \u0442\u0430\u043c \u0433\u0434\u0435 \u0432\u044b \u043f\u0438\u0441\u0430\u043b\u0438, \u0447\u0442\u043e \u0437\u043e\u043b\u043e\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0442\u0440\u0430\u0447\u0435\u043d\u043e \u043f\u043e\u0437\u0436\u0435: playerGold -= kTOWER_COST; [ui_gold_lbl setString:[NSString stringWithFormat:@&quot;GOLD: %d&quot;,playerGold]]; <\/code><\/pre>\n<p>  \u041d\u043e\u0432\u044b\u0439 \u043a\u043e\u0434 \u0432\u0432\u0435\u0440\u0445\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043b\u0438 \u0437\u043e\u043b\u043e\u0442\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u0430\u043a \u0438\u0433\u0440\u043e\u043a \u0441\u0442\u0440\u043e\u0438\u0442 \u0431\u0430\u0448\u043d\u044e. \u0415\u0441\u043b\u0438 \u0445\u0432\u0430\u0442\u0430\u0435\u0442, \u0431\u0430\u0448\u043d\u044f \u0441\u0442\u0440\u043e\u0438\u0442\u0441\u044f, \u0446\u0435\u043d\u0430 \u0431\u0430\u0448\u043d\u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u043e\u043b\u043e\u0442\u0430 \u0438\u0433\u0440\u043e\u043a\u0430. \u041d\u0443\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0430\u0442\u044c \u0438\u0433\u0440\u043e\u043a\u0430 \u0437\u0430 \u0443\u0431\u0438\u0439\u0441\u0442\u0432\u043e \u0432\u0440\u0430\u0433\u043e\u0432.<br \/>  \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0432 \u043c\u0435\u0442\u043e\u0434 <b>getDamaged:<\/b>(\u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u201cif\u201d) \u0432 <b>Enemy.m<\/b>:<\/p>\n<pre><code class=\"objectivec\">[theGame awardGold:200]; <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0438\u0433\u0440\u0443 \u0438 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435, \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0437\u043e\u043b\u043e\u0442\u0430, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0430\u0441 \u0437\u043e\u043b\u043e\u0442\u0430. \u0417\u0430 \u0443\u0431\u0438\u0439\u0441\u0442\u0432\u043e \u0432\u0440\u0430\u0433\u043e\u0432 \u0437\u043e\u043b\u043e\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f. \u0412\u043e\u0441\u0445\u0438\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u043d\u0435\u043f\u0440\u0430\u0432\u0434\u0430 \u043b\u0438?<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/cdn1.raywenderlich.com\/wp-content\/uploads\/2012\/07\/photo22-480x320.png\" alt=\"image\"\/><\/p>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043c\u0443\u0437\u044b\u043a\u0438!<br \/>  \u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 <b>HelloWorldLayer.m<\/b>:<\/p>\n<pre><code class=\"objectivec\">\/\/\u0412 \u0432\u0435\u0440\u0445\u0443\u0448\u043a\u0435 \u0444\u0430\u0439\u043b\u0430: #import &quot;SimpleAudioEngine.h&quot;   \/\/\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 init: (\u0432\u043d\u0443\u0442\u0440\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f 'if') [[SimpleAudioEngine sharedEngine] playBackgroundMusic:@&quot;8bitDungeonLevel.mp3&quot; loop:YES];   \/\/\u0412\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 ccTouchesBegan, \u043f\u0435\u0440\u0435\u0434 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Tower: [[SimpleAudioEngine sharedEngine] playEffect:@&quot;tower_place.wav&quot;];   \/\/\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 getHpDamage [[SimpleAudioEngine sharedEngine] playEffect:@&quot;life_lose.wav&quot;]; <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432 <b>Enemy.m<\/b>:<\/p>\n<pre><code class=\"objectivec\">\/\/\u0412\u0432\u0435\u0440\u0445\u0443 \u0444\u0430\u0439\u043b\u0430: #import &quot;SimpleAudioEngine.h&quot;   \/\/\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 getDamaged: [[SimpleAudioEngine sharedEngine] playEffect:@&quot;laser_shoot.wav&quot;]; <\/code><\/pre>\n<p>  \u0412\u0441\u0435! \u0412\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438! \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0438\u0433\u0440\u0443, \u043a\u0430\u043a \u0432\u0430\u043c \u0440\u0435\u0442\u0440\u043e \u0437\u0432\u0443\u043a\u0438?!<br \/>  \u0421\u044d\u043c\u043f\u043b \u043f\u0440\u043e\u0435\u043a\u0442 \u0441\u043e \u0432\u0441\u0435\u043c \u0447\u0442\u043e \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0432\u044b\u0448\u0435: <a href=\"http:\/\/cdn4.raywenderlich.com\/downloads\/TowerDefenseFinished.zip\">TowerDefenseFinished.zip<\/a>          \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\/162733\/\"> http:\/\/habrahabr.ru\/post\/162733\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">       \u0416\u0430\u043d\u0440 Tower Defence \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0445 \u0436\u0430\u043d\u0440\u043e\u0432 \u0438\u0433\u0440 \u043d\u0430 iOS. \u041f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u0442\u043e\u043c\u0443 \u0432\u0435\u0441\u0435\u043b\u043e\u0435 \u0432\u0440\u0435\u043c\u044f\u043f\u0440\u0435\u043f\u0440\u043e\u0432\u043e\u0436\u0434\u0435\u043d\u0438\u0435, \u0441\u0434\u043e\u0431\u0440\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439 \u0431\u0430\u0448\u0435\u043d \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0442\u043e\u0447\u043a\u0438 \u043e\u0431\u043e\u0440\u043e\u043d\u044b \u043f\u0440\u043e\u0442\u0438\u0432 \u043e\u0440\u0434 \u043c\u043e\u043d\u0441\u0442\u0440\u043e\u0432, \u043f\u044b\u0442\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u044d\u0442\u0443 \u0441\u0430\u043c\u0443\u044e \u043e\u0431\u043e\u0440\u043e\u043d\u0443 \u043f\u0440\u043e\u0440\u0432\u0430\u0442\u044c.<br \/>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0438, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 Pablo Ruiz, \u0438 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0439 \u043c\u043d\u043e\u0439 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 <a href=\"http:\/\/www.raywenderlich.com\">raywenderlich.com<\/a>.<br \/>  \u0412 \u044d\u0442\u043e\u043c \u0443\u0440\u043e\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438\u0433\u0440\u0443 Tower Defense \u0441 \u043d\u0443\u043b\u044f, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Cocos2D.<br \/>  \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u044b \u0432\u044b\u0443\u0447\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<ul>\n<li>\u041a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043e\u043b\u043d\u044b \u0432\u0440\u0430\u0433\u043e\u0432 \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438\u0445 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f. <\/li>\n<li>\u041a\u0430\u043a \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0438\u0445 \u0432\u0440\u0430\u0433\u043e\u0432 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0442\u043e\u0447\u043a\u0430\u043c(waypoint&#8217;\u0430\u043c). <\/li>\n<li>\u041a\u0430\u043a \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u0430\u0448\u043d\u0438 \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u043d\u0430 \u043a\u0430\u0440\u0442\u0435. <\/li>\n<li>\u041a\u0430\u043a \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0431\u0430\u0448\u043d\u0438 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c \u0432\u043e \u0432\u0440\u0430\u0433\u043e\u0432. <\/li>\n<li>\u041a\u0430\u043a \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c waypoint&#8217;\u044b \u0438 \u0440\u0430\u0434\u0438\u0443\u0441\u044b \u0430\u0442\u0430\u043a \u0431\u0430\u0448\u0435\u043d. <\/li>\n<\/ul>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u0443\u0440\u043e\u043a\u0430, \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u043e\u0439 \u0444\u0440\u044d\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0438\u0433\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u043d\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b \u0432\u0440\u0430\u0433\u043e\u0432, \u0431\u0430\u0448\u0435\u043d \u0438 \u043a\u0430\u0440\u0442.<br \/>  \u0414\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0440\u043e\u043a\u0430, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 Cocos2D. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u043e\u0432\u0438\u0447\u043e\u043a, \u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043b\u0435\u0433\u043a\u0438\u0435 \u0443\u0440\u043e\u043a\u0438 \u043d\u0430 <a href=\"http:\/\/www.raywenderlich.com\/tutorials#cocos2d\">\u0441\u0430\u0439\u0442\u0435 \u0420\u044d\u044f<\/a>.  <\/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-162733","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/162733","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=162733"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/162733\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=162733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=162733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=162733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}