中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

網(wǎng)站申請(qǐng)域名在線代理瀏覽網(wǎng)頁(yè)

網(wǎng)站申請(qǐng)域名,在線代理瀏覽網(wǎng)頁(yè),iapp網(wǎng)站怎么做軟件,wordpress的支付方式錨點(diǎn)的定義 錨點(diǎn)是指節(jié)點(diǎn)在進(jìn)行形狀變換、位置變動(dòng)時(shí)依據(jù)的基準(zhǔn)點(diǎn)。可以想象為釘在墻上用于固定紙張的小圖釘,或者公告欄上用于固定紙張用的圍棋狀的小磁粒。當(dāng)對(duì)某個(gè)節(jié)點(diǎn)調(diào)用setPosition時(shí),cocos2d-x即會(huì)將其錨點(diǎn)移動(dòng)到相應(yīng)位置;當(dāng)對(duì)節(jié)點(diǎn)進(jìn)行…

錨點(diǎn)的定義

錨點(diǎn)是指節(jié)點(diǎn)在進(jìn)行形狀變換、位置變動(dòng)時(shí)依據(jù)的基準(zhǔn)點(diǎn)??梢韵胂鬄獒斣趬ι嫌糜诠潭垙埖男D釘,或者公告欄上用于固定紙張用的圍棋狀的小磁粒。當(dāng)對(duì)某個(gè)節(jié)點(diǎn)調(diào)用setPosition時(shí),cocos2d-x即會(huì)將其錨點(diǎn)移動(dòng)到相應(yīng)位置;當(dāng)對(duì)節(jié)點(diǎn)進(jìn)行rotate操作時(shí),節(jié)點(diǎn)也是以錨點(diǎn)所在位置為軸心進(jìn)行旋轉(zhuǎn)的。具體的定義看CCNode.h中的setAnchorPoint說明:
* anchorPoint is the point around which all transformations and positioning manipulations take place.
* It's like a pin in the node where it is "attached" to its parent.

錨點(diǎn)的特征

在cocos2d-x中,錨點(diǎn)是向量化后的點(diǎn),比如某個(gè)480x320的節(jié)點(diǎn),錨點(diǎn)(0,0)在其左下角,錨點(diǎn)(1,1)在其右上角即(480,320)的位置,錨點(diǎn)(0.5,0.5)位于其中點(diǎn)處。注意,錨點(diǎn)可以大于(1,1)或者小于(0,0),這在后面將會(huì)給出演示。
* The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
* But you can use values higher than (1,1) and lower than (0,0) too.

錨點(diǎn)的默認(rèn)值

CCNode:- anchorPoint: (x=0,y=0) -m_bIgnoreAnchorPointForPosition(false)
CCScene/CCLayer/CCSprite:-setAnchorPoint( ccp(0.5f, 0.5f) ) -ignoreAnchorPointForPosition(true) (在相應(yīng)的構(gòu)造函數(shù)中可以看到)

注意:上面提到,設(shè)置節(jié)點(diǎn)位置時(shí)其實(shí)是將其錨點(diǎn)移動(dòng)到指定位置,這有個(gè)前提,就是CCNode的m_bIgnoreAnchorPointForPosition成員必須為false,它是告訴標(biāo)志節(jié)點(diǎn)移動(dòng)時(shí)是否忽略錨點(diǎn)的標(biāo)志。在cocos2d-x中,CCNode/CCSprite將其默認(rèn)為false,而CCScene/CCLayer則默認(rèn)為true,因此,若要使CCScene或者CCLayer根據(jù)錨點(diǎn)來移動(dòng),則要首先調(diào)用CCNode::ignoreAnchorPointForPosition(false)


錨點(diǎn)實(shí)例一:精靈的錨點(diǎn)

以下分別演示對(duì)精靈進(jìn)行變換操作(transformation/position)時(shí),錨點(diǎn)起到的作用

設(shè)置位置

// on "init" you need to initialize your instance
bool HelloWorld::init()
{//// 1. super init firstif ( !CCLayer::init() ){return false;}CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();CCSprite* sprite1 = CCSprite::create("CloseNormal.png");sprite1->setAnchorPoint( ccp(0,0) );sprite1->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));this->addChild(sprite1);CCSprite* sprite2 = CCSprite::create("CloseNormal.png");sprite2->setAnchorPoint( ccp(1,0) );sprite2->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));this->addChild(sprite2);CCSprite* sprite3 = CCSprite::create("CloseNormal.png");sprite3->setAnchorPoint( ccp(1,1) );sprite3->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));this->addChild(sprite3);CCSprite* sprite4 = CCSprite::create("CloseNormal.png");sprite4->setAnchorPoint( ccp(0,1) );sprite4->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));this->addChild(sprite4);CCSprite* sprite5 = CCSprite::create("CloseNormal.png");sprite5->setAnchorPoint( ccp(0.5,0.5) );sprite5->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));this->addChild(sprite5);return true;
}

運(yùn)行結(jié)果:


設(shè)置伸縮

bool HelloWorld::init()
{//// 1. super init firstif ( !CCLayer::init() ){return false;}CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();// 錨點(diǎn)(1,1)CCSprite* sprite1 = CCSprite::create("CloseNormal.png");sprite1->setAnchorPoint( ccp(1,1) );sprite1->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));this->addChild(sprite1);// 錨點(diǎn)、位置與sprite1相同,X軸以錨點(diǎn)為基點(diǎn)伸縮5.0倍CCSprite* sprite2 = CCSprite::create("CloseNormal.png");sprite2->setAnchorPoint( ccp(1,1) );sprite2->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));this->addChild(sprite2);sprite2->setScaleX(5.0f);// 錨點(diǎn)(0,0)CCSprite* sprite3 = CCSprite::create("CloseNormal.png");sprite3->setAnchorPoint( ccp(0,0) );sprite3->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));this->addChild(sprite3);// 錨點(diǎn)、位置與sprite3相同,X軸以錨點(diǎn)為基點(diǎn)伸縮5.0倍CCSprite* sprite4 = CCSprite::create("CloseNormal.png");sprite4->setAnchorPoint( ccp(0,0) );sprite4->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));this->addChild(sprite4);sprite4->setScaleX(5.0f);return true;
}
運(yùn)行結(jié)果

設(shè)置旋轉(zhuǎn)

bool HelloWorld::init()
{//// 1. super init firstif ( !CCLayer::init() ){return false;}CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();// 錨點(diǎn)(0,0)CCSprite* sprite3 = CCSprite::create("CloseNormal.png");sprite3->setAnchorPoint( ccp(0,0) );sprite3->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));this->addChild(sprite3);// 錨點(diǎn)、位置與sprite3相同,X軸以錨點(diǎn)為軸順時(shí)針旋轉(zhuǎn)90°CCSprite* sprite4 = CCSprite::create("CloseNormal.png");sprite4->setAnchorPoint( ccp(0,0) );sprite4->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));this->addChild(sprite4);sprite4->setRotation(90);	// 順時(shí)針旋轉(zhuǎn)90°return true;
}
運(yùn)行結(jié)果


設(shè)置彎曲

bool HelloWorld::init()
{//// 1. super init firstif ( !CCLayer::init() ){return false;}CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();// 錨點(diǎn)(0,0)CCSprite* sprite3 = CCSprite::create("CloseNormal.png");sprite3->setAnchorPoint( ccp(0,0) );sprite3->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));this->addChild(sprite3);// 錨點(diǎn)、位置與sprite3相同,以錨點(diǎn)為固定點(diǎn),X軸向右彎曲45°CCSprite* sprite4 = CCSprite::create("CloseNormal.png");sprite4->setAnchorPoint( ccp(0,0) );sprite4->setPosition(ccp(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2));this->addChild(sprite4);sprite4->setSkewX(45);return true;
}
運(yùn)行結(jié)果

錨點(diǎn)實(shí)例二:層的錨點(diǎn)

cocos2d-x中對(duì)CCLayer對(duì)象setPosition時(shí),若希望以錨點(diǎn)為基點(diǎn),則需要開啟bIgnoreAnchorPointForPosition標(biāo)志,否則setPosition時(shí)不考慮錨點(diǎn)因素。

設(shè)置位置

bool HelloWorld::init()
{//// 1. super init firstif ( !CCLayer::init() ){return false;}CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();// 創(chuàng)建一個(gè)綠色層CCLayerColor* layer1 = CCLayerColor::create(ccc4(0,255,0,255), 100, 50);layer1->setAnchorPoint( ccp(0.5,0.5) );	// 設(shè)置錨點(diǎn)為中點(diǎn)// layer->ignoreAnchorPointForPosition(false);layer1->setPosition(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2);	// 移動(dòng)到窗口中點(diǎn)this->addChild(layer1);// 創(chuàng)建一個(gè)黃色層CCLayerColor* layer2 = CCLayerColor::create(ccc4(255,255,0,255), 100, 50);layer2->setAnchorPoint( ccp(0.5,0.5) );	// 設(shè)置錨點(diǎn)為中點(diǎn)layer2->ignoreAnchorPointForPosition(false);layer2->setPosition(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2);	// 移動(dòng)到窗口中點(diǎn)this->addChild(layer2);return true;
}

運(yùn)行結(jié)果

參考資料

1. cocos2d-x AnchorPoint錨點(diǎn)

2. CSS3中的transform變形詳解


http://www.risenshineclean.com/news/22788.html

相關(guān)文章:

  • 如何找人幫我做網(wǎng)站推廣百度熱門關(guān)鍵詞排名
  • 阿里巴巴網(wǎng)站怎么做推廣方案網(wǎng)站排名優(yōu)化推廣
  • 2024房?jī)r(jià)即將暴漲十大城市重慶seo優(yōu)化公司
  • 男女做暖暖的試看網(wǎng)站大全安徽seo推廣公司
  • 有哪些專做自然風(fēng)景圖片的網(wǎng)站百度信息流投放在哪些平臺(tái)
  • 網(wǎng)站搭建教學(xué)小吳seo博客
  • 互動(dòng)平臺(tái)羅馬復(fù)興廣州seo站內(nèi)優(yōu)化
  • 公司做網(wǎng)站需要準(zhǔn)備什么東西整合營(yíng)銷策略有哪些
  • 珠海移動(dòng)網(wǎng)站建設(shè)報(bào)價(jià)網(wǎng)站制作公司怎么找
  • 網(wǎng)站開發(fā)線框四年級(jí)下冊(cè)數(shù)學(xué)優(yōu)化設(shè)計(jì)答案
  • 阿拉丁建站系統(tǒng)谷歌網(wǎng)站優(yōu)化推廣
  • 愛做片視頻網(wǎng)站百度收錄入口
  • 做網(wǎng)站上傳照片的尺寸搜索排名優(yōu)化公司
  • 網(wǎng)站開發(fā)框架圖欽州seo
  • 哪有做網(wǎng)站的 優(yōu)幫云seo超級(jí)外鏈發(fā)布
  • 西寧網(wǎng)站制作哪家公司好網(wǎng)站設(shè)計(jì)模板網(wǎng)站
  • 韶關(guān)網(wǎng)站建設(shè)廣告聯(lián)盟平臺(tái)掛機(jī)賺錢
  • 采購(gòu)網(wǎng)站平臺(tái)遼陽(yáng)網(wǎng)站seo
  • 建站行業(yè)現(xiàn)狀探討今日頭條權(quán)重查詢
  • 網(wǎng)站搭建費(fèi)用明細(xì)樂天seo培訓(xùn)
  • 蒙山縣網(wǎng)站建設(shè)鞍山seo外包
  • 個(gè)人證書查詢網(wǎng)全國(guó)聯(lián)網(wǎng)南寧seo優(yōu)化公司排名
  • 網(wǎng)站設(shè)計(jì)主要包含3個(gè)方面市場(chǎng)調(diào)研報(bào)告萬能模板
  • 如何做網(wǎng)站拉動(dòng)條黑帽seo是什么
  • 網(wǎng)頁(yè)設(shè)計(jì)怎樣設(shè)置圖片大小公司seo排名優(yōu)化
  • 網(wǎng)站建設(shè)開發(fā)軟件有哪些關(guān)鍵詞推廣優(yōu)化排名品牌
  • asp 網(wǎng)站開發(fā) 軟件怎么做網(wǎng)絡(luò)平臺(tái)
  • 如何做好網(wǎng)站管理工作深圳網(wǎng)絡(luò)推廣代運(yùn)營(yíng)
  • 即墨城鄉(xiāng)建設(shè)局網(wǎng)站2345瀏覽器官網(wǎng)
  • 如何找做網(wǎng)站的公司網(wǎng)絡(luò)廣告的形式