本文整理汇总了C++中SpriteBatchNode::setAnchorPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ SpriteBatchNode::setAnchorPoint方法的具体用法?C++ SpriteBatchNode::setAnchorPoint怎么用?C++ SpriteBatchNode::setAnchorPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpriteBatchNode
的用法示例。
在下文中一共展示了SpriteBatchNode::setAnchorPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
//实现PianoLayer类中的init方法,初始化布景
bool PianoLayer::init()
{
//调用父类的初始化
if ( !Layer::init() )
{
return false;
}
degree = 0;
musicFlag = false;
pauseFlag = false;
instrumentName = "piano";
instrumentNumber = 1;
changeFlag = true;
musicNum = 0;
//获取可见区域尺寸
Size visibleSize = Director::getInstance()->getVisibleSize();
//获取可见区域原点坐标
Point origin = Director::getInstance()->getVisibleOrigin();
Sprite* volume = Sprite::create(pic_RESOURE_PATH + "volume_cn.png"); //音量
volumeSize = volume->getContentSize();
volume->setScale(1.2);
volume->setPosition(Point(volumeSize.width/2 + 20, visibleSize.height - volumeSize.height/2));
this->addChild(volume, 2);
exit = Sprite::create(pic_RESOURE_PATH + "exit.png"); //退出
Size exitSize = exit->getContentSize();
exit->setScale(1.2);
exit->setPosition(Point(visibleSize.width - exitSize.width/2, visibleSize.height - exitSize.height/2));
this->addChild(exit, 2);
slider = Slider::create();
slider->loadBarTexture(pic_RESOURE_PATH + "soundBackGround.png");
slider->loadSlidBallTextures(pic_RESOURE_PATH + "transparent.png",pic_RESOURE_PATH + "transparent.png", "");
slider->loadProgressBarTexture(pic_RESOURE_PATH + "sound.png");
slider->setAnchorPoint(Point(0, 0.5));
sliderSize = slider->getContentSize();
slider->setPercent(CocosDenshion::SimpleAudioEngine::getInstance()->getEffectsVolume()*100);
slider->setPosition(Point(volumeSize.width*1.2 + 20, visibleSize.height - volumeSize.height/2));
slider->addEventListener(CC_CALLBACK_2(PianoLayer::sliderEvent, this));
this->addChild(slider, 5);
instrument = Sprite::create(pic_RESOURE_PATH + "piano_cn.png"); //选择
Size selectSize = instrument->getContentSize();
instrument->setPosition(
Point(
visibleSize.width - exitSize.width - selectSize.width/2 -20,
visibleSize.height - selectSize.height/2
));
this->addChild(instrument, 2);
selection = Sprite::create(pic_RESOURE_PATH + "back.png"); //背景
selection->setPosition(
Point(
visibleSize.width - exitSize.width - selectSize.width/2 -20,
visibleSize.height - selectSize.height/2
));
this->addChild(selection, 1);
Sprite* left = Sprite::create(pic_RESOURE_PATH + "left.png"); //左键
leftSize = left->getContentSize();
left->setScale(SCALE);
left->setPosition(
Point(
leftSize.width/2*SCALE + 10,
visibleSize.height - volumeSize.height - leftSize.height*SCALE/2 - 5
));
this->addChild(left, 2);
Sprite* right = Sprite::create(pic_RESOURE_PATH + "right.png"); //右键
rightSize = right->getContentSize();
right->setScale(SCALE);
right->setPosition(
Point(
visibleSize.width - rightSize.width*SCALE/2 - 10,
visibleSize.height - volumeSize.height - rightSize.height*SCALE/2 - 5
));
this->addChild(right, 2);
//第二个参数为最大储存数
SpriteBatchNode* batchNode = SpriteBatchNode::create(pic_RESOURE_PATH + "white_small.jpg", 50); //小键盘
batchNode->setAnchorPoint(Point(0, 0));
batchNode->setPosition(
Point(
leftSize.width*SCALE + LEFT_INTERVAL,
visibleSize.height - volumeSize.height - ABOVE_INTERVAL
));
this->addChild(batchNode);
for(int i = 0; i<PIANO_KEY; i++) //小键盘
{
Sprite* whiteSmall = Sprite::createWithTexture(batchNode->getTexture(), Rect(0, 0, 34, 57));
whiteSmall->setScale(SCALE);
whiteSmall->setAnchorPoint(Point(0, 0));
smallSize = whiteSmall->getContentSize();
whiteSmall->setPosition(Point(i*smallSize.width*SCALE,0));
batchNode->addChild(whiteSmall, 2);
//.........这里部分代码省略.........