如何讓一個精靈跟隨觸點移動

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   2014   

出處:http://blog.csdn.net/honghaier/article/details/8117903 主要分為三步:1、在情境中建立精靈2、啟用情境所屬層CCLayer響應觸點的功能3、為情境所屬層CCLayer增加相應的響應觸時間點事件處理功能 具體實現如下:1、在HelloWorld.h 的中 init()函數中  2、在return之前3、HelloWorld.h中聲明 HelloWorld.cpp中後記    對於那個擷取觸點指標容器中的第一個元素網上搜尋內容如下            我的理解,就是Begin( )函數用來獲得第一個觸點(也就是單點觸控的),pTouches(是個複數)說明支援的是多點觸控,我們還可以通過這一變數來獲得其他的觸控點,即實現多點觸控的響應         比如(在一個例子中看到的)        if(pTouches->count() == 1){        //CCSetIterator iter = pTouches->begin();        //CCTouch *pTouch = (CCTouch *)*iter;        CCTouch *pTouch = (CCTouch *) pTouches->anyObject();         CCPoint location = pTouch->getLocation();        CCRect planeRect = m_plane->boundingBox();        if(planeRect.containsPoint(location)){//(CCRect::CCRectContainsPoint(planeRect, location)){            m_plane->setPosition(location);        }    }         

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.