cocos2d-x——坐标系统
来源:互联网 发布:世界人口钟实时数据 编辑:程序博客网 时间:2024/06/05 00:44
#include "HelloWorldScene.h"using namespace cocos2d;CCScene* HelloWorld::scene(){ CCScene * scene = NULL; do { // 'scene' is an autorelease object scene = CCScene::node(); CC_BREAK_IF(! scene); // 'layer' is an autorelease object HelloWorld *layer = HelloWorld::node(); CC_BREAK_IF(! layer); // add layer as a child to scene scene->addChild(layer); } while (0); // return the scene return scene;}// on "init" you need to initialize your instancebool HelloWorld::init(){ bool bRet = false; do { ////////////////////////////////////////////////////////////////////////// // super init first ////////////////////////////////////////////////////////////////////////// CC_BREAK_IF(! CCLayer::init()); ////////////////////////////////////////////////////////////////////////// // add your codes below... ////////////////////////////////////////////////////////////////////////// /*颜色涂层*/CCLayerColor* colorLayer = CCLayerColor::layerWithColor(ccc4f(255,255,0,255));//this->addChild(colorLayer);/*渐变色图层CCLayerGradient::layerWithColor(ccc4f(255,0,0,255),ccc4f(0,255,0,255),ccp(0.8,0.8))3个参数分别为:开始颜色、结束颜色、颜色改变的点需要注意的是颜色改变的点的两个参数都以比例的形式给出。如这里的ccp(0.8,0.8)中的0.8是指占x轴的0.8*/CCLayerGradient* gradientLayer = CCLayerGradient::layerWithColor(ccc4f(255,0,0,255),ccc4f(0,255,0,255),ccp(0.8,0.8));//this->addChild(gradientLayer);//CCLayerMultiplex* grounLayer = CCLayerMultiplex::layerWithLayers(colorLayer,gradientLayer);//this->addChild(grounLayer);//grounLayer->switchTo(1);//切换到索引为1的图层。(索引从0开始算)//grounLayer->switchToAndReleaseMe(1);//与上一个的不同之处在于这个切换后会释放该图层的空间,而且可能会产生异常/*CCLog():用于向控制台打印日志this->getAnchorPoint() :获取当前图层或精灵的锚点结论:图层或精灵(其他的也是这样,例如什么CCLayer)的默认锚点都是0.5、0.5*///CCSprite* sprite = CCSprite::spriteWithFile("CloseNormal.png");//CCLog("layer:(%f , %f)",this->getAnchorPoint().x,this->getAnchorPoint().y);//CCLog("sprite:(%f , %f)",sprite->getAnchorPoint().x,this->getAnchorPoint().y);CCLayerColor* colorLayer1 = CCLayerColor::layerWithColorWidthHeight(ccc4f(255,0,0,255),480,320);this->addChild(colorLayer1);CCLog("colorLayer = (%f , %f)",colorLayer1->getAnchorPoint().x,colorLayer1->getAnchorPoint().y);colorLayer1->setPosition(ccp(240,160));//这两行的意思是:采用锚点作为作用点,将作用点的位置设为100,100colorLayer1->setIsRelativeAnchorPoint(true);//如果不加这一行,那么意思就变成了“将当前作用点的位置设为100,100(默认是左下角)”colorLayer1->setAnchorPoint(ccp(0,0));//加上这一句话后,这三句话的意思就变成了:将锚点的坐标设为0,0;采用锚点作为作用点;将锚点移至240,160 bRet = true; } while (0); return bRet;}void HelloWorld::menuCloseCallback(CCObject* pSender){ // "close" menu item clicked CCDirector::sharedDirector()->end();}
1 0
- cocos2d-x——坐标系统
- cocos2d-x坐标系统
- cocos2d-x坐标系统
- cocos2d-x坐标系统
- cocos2d-x坐标系统
- cocos2d-x坐标系统
- cocos2d-x 坐标系统
- cocos2d-x坐标系统
- cocos2d-x坐标系统
- Cocos2d-x 详解坐标系统
- Cocos2d-x 详解坐标系统
- Cocos2d-x 详解坐标系统
- 理解Cocos2d-x坐标系统
- 06 Cocos2d-x坐标系统
- Cocos2d-x 详解坐标系统
- Cocos2d-x 详解坐标系统
- Cocos2d-x 详解坐标系统
- Cocos2d-x 详解坐标系统
- 。。。
- ffmpeg交叉编译指南
- UIWebView的用法
- 回忆2013
- Android 线程同步 ConditionVariable的用法
- cocos2d-x——坐标系统
- springmvc+freemarker的简单demo
- jQuery Ajax 全解析
- ffmpeg编解码应用
- nginx+fastcgi+c/c++源码安装配置
- Android基于位置的服务
- 查看LINUX服务器序列号
- Python PEP规范
- 邪恶的浏览器DNS缓存