本文整理汇总了C++中CCClippingNode::setStencil方法的典型用法代码示例。如果您正苦于以下问题:C++ CCClippingNode::setStencil方法的具体用法?C++ CCClippingNode::setStencil怎么用?C++ CCClippingNode::setStencil使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCClippingNode
的用法示例。
在下文中一共展示了CCClippingNode::setStencil方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
bool Background::Init()
{
do
{
CCNodeLoaderLibrary * ccNodeLoaderLibraryLeft = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
CCBReader * ccbReaderLeft = new CCBReader(ccNodeLoaderLibraryLeft);
CCNode * bgLeft = ccbReaderLeft->readNodeGraphFromFile("ccb/background.ccbi", this);
CCBAnimationManager* animationManagerLeft = ccbReaderLeft->getAnimationManager();
animationManagerLeft->runAnimationsForSequenceNamed("left");
ccbReaderLeft->release();
CCNodeLoaderLibrary * ccNodeLoaderLibraryRight = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
CCBReader * ccbReaderRight = new CCBReader(ccNodeLoaderLibraryRight);
CCNode * bgRight = ccbReaderRight->readNodeGraphFromFile("ccb/background.ccbi", this);
CCBAnimationManager* animationManagerRight = ccbReaderRight->getAnimationManager();
animationManagerRight->runAnimationsForSequenceNamed("right");
ccbReaderRight->release();
CCClippingNode * clippingNodeLeft = CCClippingNode::create();
addChild(clippingNodeLeft);
clippingNodeLeft->addChild(bgLeft,enZOrderBack,enTagBgLeft);
CCDrawNode *shapeLeft = CCDrawNode::create();
static CCPoint triangleLeft[3];
triangleLeft[0] = ccp(0, 0);
triangleLeft[1] = ccp(SCREEN_WIDTH,0);
triangleLeft[2] = ccp(0,SCREEN_HEIGHT);
static ccColor4F green = {0, 1, 0, 1};
shapeLeft->drawPolygon(triangleLeft, 3, green, 0, green);
clippingNodeLeft->setStencil(shapeLeft);
clippingNodeLeft->setInverted(false);
CCClippingNode * clippingNodeRight = CCClippingNode::create();
addChild(clippingNodeRight);
clippingNodeRight->addChild(bgRight,enZOrderBack,enTagBgRight);
CCDrawNode *shapeRight = CCDrawNode::create();
static CCPoint triangleRight[3];
triangleRight[0] = ccp(SCREEN_WIDTH, SCREEN_HEIGHT);
triangleRight[1] = ccp(SCREEN_WIDTH,0);
triangleRight[2] = ccp(0,SCREEN_HEIGHT);
// static ccColor4F green = {0, 1, 0, 1};
shapeRight->drawPolygon(triangleRight, 3, green, 0, green);
clippingNodeRight->setStencil(shapeRight);
clippingNodeRight->setInverted(false);
m_CraterArrayLeft = CCArray::create();
m_CraterArrayLeft->retain();
m_CraterArrayRight = CCArray::create();
m_CraterArrayRight->retain();
m_CraterArrayLeftDeleted = CCArray::create();
m_CraterArrayLeftDeleted->retain();
m_CraterArrayRightDeleted = CCArray::create();
m_CraterArrayRightDeleted->retain();
return true;
} while (false);
CCLog("Function Background::Init Error!");
return false;
}
示例2: setup
void ScrollViewDemo::setup()
{
CCClippingNode *clipper = CCClippingNode::create();
clipper->setTag( kTagClipperNode );
clipper->setContentSize( CCSizeMake(200, 200) );
clipper->setAnchorPoint( ccp(0.5, 0.5) );
clipper->setPosition( ccp(this->getContentSize().width / 2, this->getContentSize().height / 2) );
clipper->runAction(CCRepeatForever::create(CCRotateBy::create(1, 45)));
this->addChild(clipper);
CCDrawNode *stencil = CCDrawNode::create();
CCPoint rectangle[4];
rectangle[0] = ccp(0, 0);
rectangle[1] = ccp(clipper->getContentSize().width, 0);
rectangle[2] = ccp(clipper->getContentSize().width, clipper->getContentSize().height);
rectangle[3] = ccp(0, clipper->getContentSize().height);
ccColor4F white = {1, 1, 1, 1};
stencil->drawPolygon(rectangle, 4, white, 1, white);
clipper->setStencil(stencil);
CCSprite *content = CCSprite::create(s_back2);
content->setTag( kTagContentNode );
content->setAnchorPoint( ccp(0.5, 0.5) );
content->setPosition( ccp(clipper->getContentSize().width / 2, clipper->getContentSize().height / 2) );
clipper->addChild(content);
m_bScrolling = false;
this->setTouchEnabled(true);
}
示例3: startWithTarget
void CCClipOut::startWithTarget(CCNode *pTarget) {
CCAssert(dynamic_cast<CCClippingNode*>(pTarget) != NULL, "CCClipOut target must be a CCClippingNode instance");
CCActionInterval::startWithTarget(pTarget);
// ensure the stencil of clipper is CCDrawNode
CCClippingNode* clipper = (CCClippingNode*)pTarget;
CCNode* stencil = clipper->getStencil();
if(dynamic_cast<CCDrawNode*>(stencil) == NULL) {
clipper->setStencil(CCDrawNode::create());
}
// direction radian
// treat is like a clip in
float r = ccpToAngle(ccp(-m_direction.x, -m_direction.y));
m_cos = cosf(r);
m_sin = sinf(r);
// max distance along direction
const CCSize& size = pTarget->getContentSize();
m_distance = size.width * fabsf(m_cos) + size.height * fabsf(m_sin);
// calculate fixed edge endpoints
if(r > M_PI_2) {
float p1Len = size.width * cosf(r - M_PI_2);
m_p1.x = size.width - p1Len * cosf(r - M_PI_2);
m_p1.y = -p1Len * sinf(r - M_PI_2);
float p2Len = size.height * sinf(r - M_PI_2);
m_p2.x = size.width + p2Len * cosf(r - M_PI_2);
m_p2.y = p2Len * sinf(r - M_PI_2);
} else if(r >= 0) {
float p1Len = size.height * m_cos;
m_p1.x = p1Len * cosf(r + M_PI_2);
m_p1.y = p1Len * sinf(r + M_PI_2);
float p2Len = size.width * m_sin;
m_p2.x = p2Len * cosf(r - M_PI_2);
m_p2.y = p2Len * sinf(r - M_PI_2);
} else if(r < -M_PI_2) {
float p1Len = size.height * sinf(-r - M_PI_2);
m_p1.x = size.width + p1Len * cosf(-r - M_PI_2);
m_p1.y = size.height - p1Len * sinf(-r - M_PI_2);
float p2Len = size.width * cosf(-r - M_PI_2);
m_p2.x = size.width - p2Len * cosf(-r - M_PI_2);
m_p2.y = size.height + p2Len * sinf(-r - M_PI_2);
} else {
float p1Len = size.width * sinf(-r);
m_p1.x = p1Len * cosf(r + M_PI_2);
m_p1.y = size.height + p1Len * sinf(r + M_PI_2);
float p2Len = size.height * cosf(-r);
m_p2.x = -p2Len * cosf(r + M_PI_2);
m_p2.y = size.height - p2Len * sinf(r + M_PI_2);
}
}
示例4: initData
bool UIMakeProgress::initData(const char* fileName, const char* actionName)
{
//init game Data
//元素遮罩
CCSprite* maskSprite = CCSprite::createWithSpriteFrameName(fileName);
m_progressSprite = CCSprite::createWithSpriteFrameName(fileName);
//血条开始位置和最后位置
m_spriteStartPos = maskSprite->getPositionX() - maskSprite->getContentSize().width/2;
m_spriteEndPos = maskSprite->getPositionX() + maskSprite->getContentSize().width/2;
//血量上的动作
CCSprite* m_actionSprite = CCSprite::createWithSpriteFrameName(actionName);
m_actionSprite->setPosition(ccp(m_progressSprite->getContentSize().width/2, m_progressSprite->getContentSize().height/2));
m_actionSprite->setColor(ccc3(108, 249, 206));
m_actionSprite->setOpacity(0);
m_actionSprite->setTag(0);
m_progressSprite->addChild(m_actionSprite);
// this->addChild(m_progressSprite);
CCClippingNode* clip =CCClippingNode::create();
//设定遮罩层
clip->setStencil(maskSprite);
//设定被遮罩层
clip->addChild(m_progressSprite);
//将ClippingNode放置到舞台显示
this->addChild(clip);
//设定遮罩图层的透明度取值范围
clip->setAlphaThreshold(0);
//设定遮罩的模式true显示没有被遮起来的纹理
//如果是false就显示遮罩起来的纹理
//clip是一个显示对象(容器)
clip->setInverted(false);
return true;
}
示例5: ccp
bool Recipe26::init()
{
if ( !RecipeBase::init() )
{
return false;
}
CCSize size = CCDirector::sharedDirector()->getVisibleSize();
CCSprite* pSprite = CCSprite::create("HelloWorld.png");
pSprite->setPosition( ccp(size.width/2, size.height/2) );
CCSprite* pMask = CCSprite::create("mask_star.png");
pMask->setPosition(ccp(size.width/2, size.height/2));
CCClippingNode* pClip = CCClippingNode::create();
pClip->setStencil(pMask);
pClip->setAlphaThreshold(0.0f);
pClip->addChild(pSprite);
this->addChild(pClip);
return true;
}
示例6: init
bool CSignLayer::init()
{
if (BaseLayer::init())
{
MaskLayer* lay = MaskLayer::create("CSignLayermask");
lay->setContentSize(CCSizeMake(2824,640));
LayerManager::instance()->push(lay);
m_ui = LoadComponent("Sign.xaml"); // SelectSkill
m_ui->setPosition(VCENTER);
this->addChild(m_ui);
this->setOpacity(180);
//背景框
CImageView* pImageRect = (CImageView*)m_ui->findWidgetById("board_sign");
//添加一个裁切层
CCClippingNode* pClip = CCClippingNode::create();
CImageView* pImage = UICloneMgr::cloneImageView(pImageRect);
pImage->setAnchorPoint(ccp(0.5f, 0.5f));
pImage->setPosition(ccp(pImage->getContentSize().width/2, pImage->getContentSize().height/2));
pClip->setStencil(pImage);
pClip->setContentSize(pImageRect->getContentSize());
pClip->setAnchorPoint(pImageRect->getAnchorPoint());
pClip->setPosition(pImageRect->getPosition());
pImageRect->getParent()->addChild(pClip, pImageRect->getZOrder()+1);
m_pClip = pClip;
//展示区图片
m_show_info_scroll = (CScrollView*)m_ui->findWidgetById("scroll_info");
m_show_info_scroll->setDirection(eScrollViewDirectionVertical);
m_show_info_scroll->setBounceable(true);
m_pInfo1 = (CLabel*)m_ui->findWidgetById("info_1");
CC_SAFE_RETAIN(m_pInfo1);
m_pInfo1->removeFromParentAndCleanup(false);
m_show_info_scroll->getContainer()->addChild(m_pInfo1);
m_pInfo1->setAnchorPoint(ccp(0, 1));
CC_SAFE_RELEASE(m_pInfo1);
m_pInfo2 = (CLabel*)m_ui->findWidgetById("info_2");
CC_SAFE_RETAIN(m_pInfo2);
m_pInfo2->removeFromParentAndCleanup(false);
m_show_info_scroll->getContainer()->addChild(m_pInfo2);
m_pInfo2->setAnchorPoint(ccp(0, 1));
CC_SAFE_RELEASE(m_pInfo2);
updateShowInfoScroll();
m_show_info_scroll->setVisible(false);
CCNode* pMaskInfo = (CCNode*)m_ui->findWidgetById("mask_info");
pMaskInfo->setVisible(false);
m_pLineEffect = new CLineLightEffect;
m_pLineEffect->bindUI(m_ui);
m_pLineEffect->bindRectEffect(pImageRect);
this->addChild(m_pLineEffect, 999);
m_pYellowTip = CCSprite::create("sign/lightbox5.png");
m_pYellowTip->setAnchorPoint(ccp(0.5f, 0.0f));
m_pYellowTip->setScale(0.8f);
m_pYellowTip->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCMoveBy::create(0.3f, ccp(0, -10)), CCMoveBy::create(0.3f, ccp(0, 10)))));
m_ui->addChild(m_pYellowTip, 50);
m_pYellowTipText = UICloneMgr::cloneLable((CLabel*)m_ui->findWidgetById("day1"));
m_pYellowTipText->setAnchorPoint(ccp(0.5f, 0.5f));
m_pYellowTipText->setPosition(ccp(m_pYellowTip->getContentSize().width/2, m_pYellowTip->getContentSize().height/2+12));
m_pYellowTipText->setScale(1.2f);
m_pYellowTip->addChild(m_pYellowTipText);
m_pYellowTip->setVisible(false);
return true;
}
return false;
}
示例7: init
bool TipsScene::init()
{
if ( !CCLayer::init())
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
mCallFunc = NULL;
targetRidus = 100;
//创建一个遮罩层。
CCLayerColor* pLayer;
if (isHasTarget && !istouchRemove)
{
pLayer=CCLayerColor::create(ccc4(0,0,0,200));
/*创建剪裁节点*/
CCClippingNode* pClip = CCClippingNode::create() ;
pClip->setInverted(true) ;//设置是否反向,将决定画出来的区域是透明的还是黑色的。
this->addChild(pClip) ;
/*注意将LayerColor层添加到剪裁节点上*/
pClip->addChild(pLayer) ;
//模板
CCDrawNode* pStencil = CCDrawNode::create() ;
static ccColor4F red = {1,0,0,1} ;
float radius = targetRidus/2 ;
const int nCount = 200 ;
const float angel = 2.0 * (float)M_PI/nCount ;
static CCPoint circle[nCount] ;
for (int i=0; i<nCount; i++) {
float radian = i*angel ; //弧度
circle[i].x = radius * cosf(radian) ;
circle[i].y = radius * sinf(radian) ;
}
pStencil->drawPolygon(circle, nCount, red, 0, red) ;
pStencil->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleBy::create(0.2f, 0.9f), CCScaleTo::create(0.2f, 1)))) ;
pStencil->setPosition(targetPoint);
pClip->setStencil(pStencil) ; //将这个区域从剪裁节点上面抠出来。Stencil是模板的意思
}
else if (shouldPauseGame)
{
pLayer=CCLayerColor::create(ccc4(0,0,0,100));
this->addChild(pLayer) ;
}
else
{
}
if (isAutoRemove)
{
scheduleOnce(schedule_selector(TipsScene::scheduleResumeGame),2.8);
scheduleOnce(schedule_selector(TipsScene::scheduleRemove),3.0f);
}
CCSprite* tipsbg = CCSprite::create("tipbg.png");
//tipsbg -> setPosition(ccp(375,260));
tipsbg -> setPosition(ccp(375,260 + 160));
addChild(tipsbg);
mTipsWord = CCLabelTTF::create("","Arial",20);
mTipsWord -> setColor(ccYELLOW);
//mTipsWord -> setPosition(ccp(400,240));
mTipsWord -> setPosition(ccp(400,240 + 160));
addChild(mTipsWord);
setTouchEnabled(true);
if (shouldPauseGame)
{
BattleManage* pauseLayer = BattleManage::oneself;
pauseLayer -> pauseSchedulerAndActions();
}
return true;
}
示例8: Init
//.........这里部分代码省略.........
this->addChild(pMenu, 1);
CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - pLabel->getContentSize().height));
this->addChild(pLabel, 1,1);
CCSprite* pSprite = CCSprite::create("HelloWorld.png");
pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
this->addChild(pSprite, 0);
setTouchEnabled(true);
// /* Create an autorelease CCNodeLoaderLibrary. */
// CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
//// ccNodeLoaderLibrary->registerCCNodeLoader("MainScene", MainSceneLayerLoader::loader());
// /* Create an autorelease CCBReader. */
// cocos2d::extension::CCBReader * ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
// /* Read a ccbi file. */
// CCNode * node = ccbReader->readNodeGraphFromFile("MainScene.ccbi", this);
// m_AnimationManager = ccbReader->getAnimationManager();
// m_AnimationManager->runAnimationsForSequenceNamed("default");
// m_bMenuShow = true;
// ccbReader->release();
// if(node != NULL) {
// this->addChild(node);
// }
// CCFilteredSpriteWithOne* pSpOne = CCFilteredSpriteWithOne::create("Icon-144.png");
// addChild(pSpOne);
// pSpOne->setPosition(ccp(visibleSize.width/2,visibleSize.height/2));
// CCGrayFilter* pF = CCGrayFilter::create(ccc4f(0.2, 0.3, 0.5, 0.1));
// pSpOne->setFilter(pF);
//
// CCFilteredSpriteWithMulti* pSpMulti = CCFilteredSpriteWithMulti::create("Icon-144.png");
// addChild(pSpMulti);
// pSpMulti->setPosition(ccp(visibleSize.width/2,visibleSize.height/4));
// CCHueFilter* pF1 = CCHueFilter::create(240);
// CCSaturationFilter* pF2 = CCSaturationFilter::create(1.5);
// CCBrightnessFilter* pF3 = CCBrightnessFilter::create(-0.4);
// CCArray* pArray = CCArray::create();
// pArray->addObject(pF1);
// pArray->addObject(pF2);
// pArray->addObject(pF3);
// pSpMulti->setFilters(pArray);
// //test setBlendFunc
// ccBlendFunc cbl = { GL_SRC_ALPHA , GL_ONE };
// CCRotateBy * ccRotateBy = CCRotateBy::create(20.0f, 360);
// CCRepeatForever * ccRepeatForever = CCRepeatForever::create(ccRotateBy);
// this->mBurstSprite->runAction(ccRepeatForever);
// pSp->setBlendFunc(cbl);
//test Shader Utils
// ShaderUtils::alphaMask(pSp, "Icon-114.png");
// ShaderUtils::colorHSL(pSp, 120, 60);
m_count = 0;
// CCSprite *sprite = CCSprite::create("Icon-144.png");
// CCSize winSize = CCDirector::sharedDirector()->getWinSize();
// CCTableView* tableView = CCTableView::create(this,ccp(sprite->getContentSize().width*4,sprite->getContentSize().height*4));
// tableView->setDirection(kCCScrollViewDirectionVertical);
// tableView->setPosition(ccp(winSize.width/3,winSize.height/3));
// tableView->setDelegate(this);
// tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
// this->addChild(tableView,0,111);
// tableView->reloadData();
// sprite->release();
//背景图片
CCSprite * background = CCSprite::create("HelloWorld.png");
background->setPosition(ccp(visibleSize.width/2,visibleSize.height/2));
this->addChild(background,0);
//创建一个裁剪节点用来实现遮罩的效果
CCClippingNode * clippingNode = CCClippingNode::create();
this->addChild(clippingNode,1);
//向裁剪节点中加入内容,这里加入的是一个透明的层
CCLayerColor * layer = CCLayerColor::create(ccc4(0,0,0,200));
clippingNode->addChild(layer);
//继续向裁剪节点中加入内容,这里加入的是一个精灵
CCSprite * sprite = CCSprite::create("Icon-144.png");
sprite->setPosition(ccp(visibleSize.width/4,visibleSize.height/2));
clippingNode->addChild(sprite);
//创建模板,裁剪节点将按照这个模板来裁剪区域
CCSprite * stencil = CCSprite::create("Icon-114.png");
stencil->setPosition(ccp(visibleSize.width/2,visibleSize.height/2));
clippingNode->setStencil(stencil);
//向裁剪节点中加入精灵,精灵的位置和裁剪的位置相同,所以最后让裁剪掉了
CCSprite * sprite2 = CCSprite::create("Icon-144.png");
sprite2->setPosition(ccp(visibleSize.width/2,visibleSize.height/2));
clippingNode->addChild(sprite2);
//这个是用来设置显示裁剪区域还是非裁剪区域的
clippingNode->setInverted(true);
//我们之前放了一张裁剪的模板,按照这个模板裁剪的时候同时按照这个alpha的值裁剪,这个值的范围是0-1
//设为0就把透明的区域裁剪掉了
// clippingNode->setAlphaThreshold(0);
return true;
}
示例9: init
bool ImageEditLayer::init(){
if (DialogLayer::init()) {
this->setTitle("头像编辑");
CCPoint middle=ccp(286, 154);
CCSize size=CCSizeMake(570,300);
CCClippingNode* clippingNode = CCClippingNode::create();
//设置裁剪区域大小
clippingNode->setContentSize(size);
clippingNode->setAnchorPoint(ccp(0.5, 0.5));
clippingNode->setPosition(middle);
m_contentLayer->addChild(clippingNode);
CCTexture2D* textrue=new CCTexture2D();
textrue->autorelease();
textrue->initWithImage(_image);
_sprite=CCSprite::createWithTexture(textrue);
_initPoint=ccp(clippingNode->getContentSize().width/2, clippingNode->getContentSize().height/2);
_sprite->setPosition(_initPoint);
CCSize spriteSize=_sprite->getContentSize();
if (size.width/spriteSize.width<size.height/spriteSize.height) {
_scale=size.width/spriteSize.width;
}else{
_scale=size.height/spriteSize.height;
}
_sprite->setScale(_scale);
clippingNode->addChild(_sprite);
//创建裁剪模板,裁剪节点将按照这个模板来裁剪区域
CCDrawNode *stencil = CCDrawNode::create();
CCPoint rectangle[4];
rectangle[0] = ccp(0, 0);
rectangle[1] = ccp(clippingNode->getContentSize().width, 0);
rectangle[2] = ccp(clippingNode->getContentSize().width, clippingNode->getContentSize().height);
rectangle[3] = ccp(0, clippingNode->getContentSize().height);
ccColor4F white = {1, 1, 1, 1};
//画一个多边形 这画一个200x200的矩形作为模板
stencil->drawPolygon(rectangle, 4, white, 1, white);
clippingNode->setStencil(stencil);
//用来设置显示裁剪区域还是非裁剪区域的
clippingNode->setInverted(false);//在裁剪区域内显示加入的内容
_clip=CCClippingNode::create();//创建裁剪节点,成员变量
_clip->setInverted(true);//设置底板可见
_clip->setAlphaThreshold(0.0f);//设置alpha为0
m_contentLayer->addChild(_clip);//添加裁剪节点
_mask=CCLayerColor::create(ccc4(0,0,0,160),size.width,size.height);
CCPoint point=ccp(middle.x-size.width/2,middle.y-size.height/2);
_mask->setPosition(point);
_clip->addChild(_mask);//为裁剪节点添加一个黑色带透明(看起了是灰色)的底板
_stencil=CCSprite::create("default_avatar.png");//使用头像原图作为模板
_stencil->setPosition(middle);
_stencil->setScale(STENCIL_SCALE);
_clip->setStencil(_stencil);//设置模版
CCSprite* queding=CCSprite::createWithSpriteFrameName("touxiang_queding.png");
CCMenuItemSprite* item=CCMenuItemSprite::create(queding, queding, this, menu_selector(ImageEditLayer::menuCallback));
item->setPosition(ccp(290,-30));//注意contentlayer坐标原点位置
item->setScale(0.7);
item->setTag(kTagConfirm);
this->addMenuItem(item,true);
CCSprite* fanhui=CCSprite::createWithSpriteFrameName("touxiang_fanhui.png");
fanhui->setScale(0.87);
CCMenuItemSprite* fanhuiItem=CCMenuItemSprite::create(fanhui, fanhui, this, menu_selector(ImageEditLayer::menuCallback));
fanhuiItem->setPosition(ccp(19,368));
fanhuiItem->setTag(kTagBack);
this->addMenuItem(fanhuiItem,true);
CCPoint contentPoint=m_contentLayer->getPosition();
_rect=CCRectMake(contentPoint.x+point.x, contentPoint.y+point.y, size.width,size.height);
return true;
}
return false;
}
示例10: CCRectMake
bool Recipe26::init()
{
if ( !RecipeBase::init() )
{
return false;
}
CCLayerColor* panelBg = CCLayerColor::create(ccc4(51, 51, 51, 255),640,1150);
panelBg->setPosition(ccp(0,0));
this->addChild(panelBg);
targetLayer = CCLayer::create();
this->addChild(targetLayer);
// 画面の幅を取得
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
// 画像ファイルとrectを指定してスプライトを作成
CCSprite *player = CCSprite::create("image/quest/shuriken_m_avatar_skillpg_18.png", CCRectMake(0, 0, 100, 100) );
// スプライトの位置を設定
player->setPosition(ccp(player->getContentSize().width*3/2, winSize.height/2));
// 後で識別できるようにタグを設定
player->setTag(1);
// スプライトをレイヤに追加
targetLayer->addChild(player);
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
TapSprite* sprite = (TapSprite*)TapSprite::create("image/quest/shuriken_m_avatar_skillpg_18.png");
sprite->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
sprite->setTag(2);
targetLayer->addChild(sprite);
// クリック用のボタン
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"image/ui/common_ui_mainButton_up.png",
"image/ui/common_ui_mainButton_down.png",
this,
menu_selector(Recipe26::testBtn1Handler));
// 表示位置を指定
pCloseItem->setPosition(ccp(winSize.width - pCloseItem->getContentSize().width / 2 ,
pCloseItem->getContentSize().height / 2));
// CCMenuItemImage から CCMenuを作成
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
// CCMenuとしての位置は(0,0)を指定
pMenu->setPosition(-150,130);
this->addChild(pMenu);
//---------------------------
CCSize size = CCDirector::sharedDirector()->getVisibleSize();
CCSprite* pSprite = CCSprite::create("image/gacha/2204401.jpg");
pSprite->setPosition( ccp(size.width/2, size.height/2) );
CCSprite* pMask = CCSprite::create("image/quest/mask_star.png");
pMask->setPosition(ccp(size.width/2, size.height/2));
CCClippingNode* pClip = CCClippingNode::create();
pClip->setStencil(pMask);
pClip->setAlphaThreshold(0.05f);
pClip->addChild(pSprite);
targetLayer->addChild(pClip);
CCMoveTo *actionMove = CCMoveTo::create(1.7f, ccp(200, 500));
pClip->runAction(CCEaseExponentialInOut::create(actionMove));
//---------------------------
// 配列のテスト
//---------------------------
int arrN[] = {5,6,9,4};
int iSize = sizeof(arrN) / sizeof(arrN[0]);
for ( int i = 0 ; i < iSize ; i++ ) {
CCLOG("ffgff : %i" , arrN[i]);
}
return true;
}