码迷,mamicode.com
首页 > 其他好文 > 详细

coco2dx 精灵类

时间:2014-10-23 22:28:08      阅读:391      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   os   ar   sp   div   on   

    CCSize size = CCDirector::sharedDirector()->getWinSize();

    CCSprite *bg = CCSprite::create("HelloWorld.png");
    bg->setPosition(ccp(size.width/2,size.height/2));//ccp CCPoint
    this->addChild(bg);

    CCSprite *sp1 = CCSprite::create("icon.png");
    sp1->setPosition(ccp(size.width*0.2,size.height*0.7));
    this->addChild(sp1);


    CCSprite *sp2 = CCSprite::create("icon.png",CCRect(28,28,29,29));
    sp2->setPosition(ccp(size.width*0.4, size.height*0.7));
    this->addChild(sp2);


    CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage("icon.png");//创建2d纹理

    CCSprite *sp3 = CCSprite::createWithTexture(texture);
    sp3->setPosition(ccp(size.width*0.6, size.height*0.7));
    this->addChild(sp3);


    CCSprite *sp4 = CCSprite::createWithTexture(texture, CCRect(0, 0, 40, 40));
    sp4->setPosition(ccp(size.width*0.8,size.height*0.7));
    this->addChild(sp4);


    CCSpriteFrame *frame = CCSpriteFrame::create("icon.png",CCRect(0,0,57,57));


    CCSprite *sp5 = CCSprite::createWithSpriteFrame(frame);//缓存帧
    sp5->setPosition(ccp(size.width*0.3,size.height*0.3));
    this->addChild(sp5);
    sp5->setScale(0.5f);
    sp5->setRotation(30.0f);//大于0顺时针小于0逆时针
    sp5->setSkewX(30);//倾斜 以图片的中央位置进行倾斜
    //sp5->setVisible(false);//不可见
    //sp5->setColor(ccc3(255,0,0));
    sp5->setOpacity(100);//0-255
    sp5->setTexture(CCTextureCache::sharedTextureCache()->addImage("CloseNormal.png"));
    /*
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("img.plist");

    CCSprite *sp6 = CCSprite::createWithSpriteFrameName("icon.png");//缓存帧
    sp6->setPosition(ccp(size.width*0.7,size.height*0.3));
    this->addChild(sp6);
    */

 

coco2dx 精灵类

标签:style   blog   color   io   os   ar   sp   div   on   

原文地址:http://www.cnblogs.com/ghgyj/p/4046976.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!