cocos2d-x+cocosbuilder 学习笔记 (二)

分享一张图片做的点击放大效果的CCMenu

CCMenuItemSprite *createScaleMenuWithOnePic(const char *path,CCObject*target,SEL_MenuHandler selector)

{

    CCSprite *spImageSprite = CCSprite::create(path);

    CCSprite *spImageSpriteHL = CCSprite::create(path);

    spImageSpriteHL->setScale(1.2);

    

    CCMenuItemSprite *pRet = new CCMenuItemSprite();

    pRet->initWithNormalSprite(spImageSprite, spImageSpriteHL, NULL, target, selector);

    pRet->autorelease();


    spImageSprite->setAnchorPoint(ccp(0.5,0.5));

    spImageSpriteHL->setAnchorPoint(ccp(0.5,0.5));

    CCSize size = spImageSprite->getContentSize();

    spImageSprite->setPosition(ccp(size.width/2,size.height /2));

    size = spImageSprite->getContentSize();

    spImageSpriteHL->setPosition(ccp(size.width/2,size.height /2));

    

    return pRet;

}



你可能感兴趣的:(cocos2d-x+cocosbuilder 学习笔记 (二))