{"id":152,"date":"2013-10-27T23:42:57","date_gmt":"2013-10-27T14:42:57","guid":{"rendered":"http:\/\/koheizi.mydns.jp\/koheizi\/?p=152"},"modified":"2014-03-03T00:32:27","modified_gmt":"2014-03-02T15:32:27","slug":"cocos2d-x-%e3%81%aeccscrollview%e3%81%8c%e6%80%aa%e3%81%97%e3%81%842","status":"publish","type":"post","link":"https:\/\/programmer.everything-beginner.com\/?p=152","title":{"rendered":"cocos2d-x \u306eCCScrollView\u304c\u602a\u3057\u3044(2)"},"content":{"rendered":"<p>\u524d\u56de\u3001<a href=\"http:\/\/koheizidaigorou.blog.fc2.com\/blog-entry-136.html\" target=\"_blank\" title=\"\u3053\u306e\u8a18\u4e8b\">\u3053\u306e\u8a18\u4e8b<\/a>\u3067\u8a71\u3057\u305f\u3001CCScrollView\u304c\u602a\u3057\u3044\u4ef6\u306e\u7d9a\u304d\u3067\u3059\u3002<br \/>\n\u3069\u3046\u3082\u3001\u3053\u306e\u95a2\u6570\u306e\u52d5\u304d\u304c\u602a\u3057\u3044\u3002<\/p>\n<pre>\r\nvoid CCScrollView::deaccelerateScrolling(float dt)\r\n{\r\n    if (m_bDragging)\r\n    {\r\n        this->unschedule(schedule_selector(CCScrollView::deaccelerateScrolling));\r\n        return;\r\n    }\r\n    float newX, newY;\r\n    CCPoint maxInset, minInset;\r\n    m_pContainer->setPosition(ccpAdd(m_pContainer->getPosition(), m_tScrollDistance));\r\n    if (m_bBounceable)\r\n    {\r\n        maxInset = m_fMaxInset;\r\n        minInset = m_fMinInset;\r\n    }\r\n    else\r\n    {\r\n        maxInset = this->maxContainerOffset();\r\n        minInset = this->minContainerOffset();\r\n    }\r\n    \/\/check to see if offset lies within the inset bounds\r\n    newX     = MIN(m_pContainer->getPosition().x, maxInset.x);\r\n    newX     = MAX(newX, minInset.x);\r\n    newY     = MIN(m_pContainer->getPosition().y, maxInset.y);\r\n    newY     = MAX(newY, minInset.y);\r\n    newX = m_pContainer->getPosition().x;\r\n    newY = m_pContainer->getPosition().y;\r\n    m_tScrollDistance     = ccpSub(m_tScrollDistance, ccp(newX - m_pContainer->getPosition().x, newY - m_pContainer->getPosition().y));\r\n    m_tScrollDistance     = ccpMult(m_tScrollDistance, SCROLL_DEACCEL_RATE);\r\n    this->setContentOffset(ccp(newX,newY));\r\n    if ((fabsf(m_tScrollDistance.x) <= SCROLL_DEACCEL_DIST &#038;&#038;\r\n    fabsf(m_tScrollDistance.y) <= SCROLL_DEACCEL_DIST) ||\r\n    newY > maxInset.y || newY < minInset.y ||\r\n    newX > maxInset.x || newX < minInset.x ||\r\n    newX == maxInset.x || newX == minInset.x ||\r\n    newY == maxInset.y || newY == minInset.y)\r\n    {\r\n      this->unschedule(schedule_selector(CCScrollView::deaccelerateScrolling));\r\n      this->relocateContainer(true);\r\n    }\r\n}\r\n<\/pre>\n<p>\u307e\u305a\u3001<br \/>\n\/\/check to see if offset lies within the inset bounds<br \/>\n\u304b\u3089\u4e0b\u306enewX, newY\u306e\u4ee3\u5165\u304c\u602a\u3057\u3059\u304e\u308b\u3002<br \/>\n\u306a\u3093\u3067\u3001\u6700\u5f8c\u306e\u5f0f\u3067\u7f6e\u304d\u63db\u3048\u3066\u3044\u308b\u304b\u3089\u3001MIN, MAX\u3057\u3066\u3044\u308b\u3068\u3053\u308d\u610f\u5473\u306a\u3044\u3093\u3058\u3083\u306a\u3044\uff1f<br \/>\n\u305d\u308c\u306b\u30c7\u30d0\u30c3\u30af\u3057\u3066\u307f\u308b\u3068\u306a\u3093\u304b\u983b\u7e41\u306b\u3001\u6700\u5f8c\u306eif\u6587\u306b\u5165\u3063\u3066\u3044\u308b\u6c17\u304c\u3059\u308b\u3002<br \/>\n\u3053\u308c\u305f\u3076\u3093\u3001\u30b9\u30af\u30ed\u30fc\u30eb\u306e\u6163\u6027\u304c\u7d42\u308f\u308b\u3068\u304d\u306b\u901a\u308b\u30eb\u30fc\u30c8\u3060\u304b\u3089\u983b\u7e41\u3058\u3083\u3060\u3081\u3060\u3088\u306d\uff1f<br \/>\nmaxContainerOffset\u304c\u9375\u306b\u306a\u308a\u305d\u3046\u306a\u304d\u304c\u3059\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u3001\u3053\u306e\u8a18\u4e8b\u3067\u8a71\u3057\u305f\u3001CCScrollView\u304c\u602a\u3057\u3044\u4ef6\u306e\u7d9a\u304d\u3067\u3059\u3002 \u3069\u3046\u3082\u3001\u3053\u306e\u95a2\u6570\u306e\u52d5\u304d\u304c\u602a\u3057\u3044\u3002 void CCScrollView::deaccelerateScrolling(float dt) { if ( [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[16],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4sUNl-2s","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/programmer.everything-beginner.com\/index.php?rest_route=\/wp\/v2\/posts\/152"}],"collection":[{"href":"https:\/\/programmer.everything-beginner.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/programmer.everything-beginner.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/programmer.everything-beginner.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/programmer.everything-beginner.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=152"}],"version-history":[{"count":2,"href":"https:\/\/programmer.everything-beginner.com\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions"}],"predecessor-version":[{"id":166,"href":"https:\/\/programmer.everything-beginner.com\/index.php?rest_route=\/wp\/v2\/posts\/152\/revisions\/166"}],"wp:attachment":[{"href":"https:\/\/programmer.everything-beginner.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=152"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/programmer.everything-beginner.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=152"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/programmer.everything-beginner.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=152"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}