zoukankan      html  css  js  c++  java
  • cocos2dx混合模式应用———制作新手引导高亮区域

    先看下效果

    制造这个椭圆高亮区域所使用原图是

    附上代码

    bool HelloWorld::init()
    {
        //////////////////////////////
        // 1. super init first
        if ( !CCLayer::init() )
        {
            return false;
        }
        
        CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
        CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
    
        …………
        …………
        
        m_pTarget = CCRenderTexture::create(visibleSize.width, visibleSize.height, kCCTexture2DPixelFormat_RGBA8888);
        m_pTarget->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
        addChild(m_pTarget, 10000);
    
        return true;
    }
    
    void HelloWorld::setHighlightRect(const cocos2d::CCRect& rect)
    {
        CCSprite* pMask = CCSprite::create("btn-about-normal.png");
        pMask->setPosition(ccp(rect.origin.x,rect.origin.y));
        pMask->setAnchorPoint(ccp(0,0));
        pMask->setScaleX(rect.size.width/pMask->getContentSize().width);
        pMask->setScaleY(rect.size.height/pMask->getContentSize().height);
    
        ccBlendFunc blend;
        blend.src = GL_ZERO;
        blend.dst = GL_ONE_MINUS_SRC_ALPHA;
        pMask->setBlendFunc(blend);
    
        m_pTarget->clear(0,0,0,0.8f);
        m_pTarget->begin();
        pMask->visit();
        m_pTarget->end();
    }
  • 相关阅读:
    推荐一份JAVA学习vip路线图,可以参考下学习路径哦
    上传视频到阿里云服务器
    微信小程序授权登陆以及获取获取openid
    Java随笔
    Java随笔
    Java随笔
    Java随笔
    Java随笔
    Java随笔
    AC自动机模板
  • 原文地址:https://www.cnblogs.com/mrblue/p/3455775.html
Copyright © 2011-2022 走看看