本文整理汇总了C++中setScaleX函数的典型用法代码示例。如果您正苦于以下问题:C++ setScaleX函数的具体用法?C++ setScaleX怎么用?C++ setScaleX使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setScaleX函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CC_CALLBACK_1
//------------------------------------------------------------------
//
// MenuLayer2
//
//------------------------------------------------------------------
MenuLayer2::MenuLayer2()
{
for( int i=0;i < 2;i++ )
{
auto item1 = MenuItemImage::create(s_PlayNormal, s_PlaySelect, CC_CALLBACK_1(MenuLayer2::menuCallback, this));
auto item2 = MenuItemImage::create(s_HighNormal, s_HighSelect, CC_CALLBACK_1(MenuLayer2::menuCallbackOpacity, this));
auto item3 = MenuItemImage::create(s_AboutNormal, s_AboutSelect, CC_CALLBACK_1(MenuLayer2::menuCallbackAlign, this));
item1->setScaleX( 1.5f );
item2->setScaleX( 0.5f );
item3->setScaleX( 0.5f );
auto menu = Menu::create(item1, item2, item3, nullptr);
auto s = Director::getInstance()->getWinSize();
menu->setPosition(Vec2(s.width/2, s.height/2));
menu->setTag( kTagMenu );
addChild(menu, 0, 100+i);
_centeredMenu = menu->getPosition();
}
_alignedH = true;
alignMenusH();
}
开发者ID:AppleJDay,项目名称:cocos2d-x,代码行数:32,代码来源:MenuTest.cpp
示例2: getPosition
void MonsterTwoSprite::AI(Point playerPos)
{
NPCSprite::AI(playerPos);
//实现自己的AI
Point pos = getPosition();
//怪物比玩家的x坐标大表示怪物在右边
if (pos.x > playerPos.x)
{
m_npc->changeDir(Left);
setScaleX(1);
}
else
{
m_npc->changeDir(Right);
setScaleX(-1);
}
float distance = pos.distance(playerPos);
if (distance <= MONSTER_AI_SHOOT_DISTANCE)
{
this->startShoot();
}
else
{
this->closeShoot();
}
}
开发者ID:minigame,项目名称:JTW,代码行数:31,代码来源:MonsterSprite.cpp
示例3: init
// on "init" you need to initialize your instance
bool LoginScene::init()
{
//////////////////////////////
// 1. super init first
if (!Layer::init())
{
return false;
}
m_iCurMsgIndex = 0;
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
//背景
auto lsBg = Sprite::create("storybg.png");
lsBg->setPosition(Vec2(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2));
lsBg->setScaleX(visibleSize.width / 640);
lsBg->setScaleY(visibleSize.height / 960);
this->addChild(lsBg, 0, 0);
//对话框
auto chatBg = Sprite::create("chatbg.png");
chatBg->setPosition(Vec2(origin.x + visibleSize.width / 2, origin.y + chatBg->getContentSize().height / 2));
chatBg->setScaleX(visibleSize.width / 640);
chatBg->setScaleY(visibleSize.height / 960);
this->addChild(chatBg, 1, TAG_CHAT_BG);
//
readStoryJson();
showNextMsg();
return true;
}
开发者ID:chongtianfeiyu,项目名称:CardGameDemo,代码行数:32,代码来源:LoginScene.cpp
示例4: addChild
void BattleFieldUI::touchButtonInit()
{//init touch buttons
auto _setBtn = Sprite::createWithSpriteFrameName("UI-1136-640_06.png");
_setBtn->setPosition3D(Vec3(VisibleSize.width - 50, VisibleSize.height - 50, 3));
_setBtn->setScale(0.8);
_setBtn->setGlobalZOrder(10);
addChild(_setBtn, 3);
auto _chest = Sprite::createWithSpriteFrameName("chest.png");
_chest->setPosition3D(Vec3(VisibleSize.width - 100, VisibleSize.height - 50, 3));
_chest->setScale(0.8);
_chest->setGlobalZOrder(10);
addChild(_chest, 3);
auto _coin = Sprite::createWithSpriteFrameName("coins.png");
_coin->setPosition3D(Vec3(VisibleSize.width - 300, VisibleSize.height - 50, 3));
_coin->setScaleX(0.8);
_coin->setScaleY(0.8);
_coin->setGlobalZOrder(10);
addChild(_coin, 3);
auto _chestAmount = Sprite::createWithSpriteFrameName("UI-1.png");
_chestAmount->setPosition3D(Vec3(VisibleSize.width - 170, VisibleSize.height - 50, 3));
_chestAmount->setScaleX(0.8);
_chestAmount->setScaleY(0.7);
_chestAmount->setGlobalZOrder(9);
addChild(_chestAmount, 2);
auto _coinAmount = Sprite::createWithSpriteFrameName("UI-1.png");
_coinAmount->setPosition3D(Vec3(VisibleSize.width - 370, VisibleSize.height - 50, 3));
_coinAmount->setScaleX(0.8);
_coinAmount->setScaleY(0.7);
_coinAmount->setGlobalZOrder(9);
addChild(_coinAmount, 2);
}
开发者ID:WhatTeam,项目名称:FantasyLand,代码行数:35,代码来源:BattleFieldUI.cpp
示例5: updatemonstermove
void battbleScene::updatemonstermove(float dt)
{
std::vector<Monster*>::iterator t;
for(t=monsterArr.begin();t!=monsterArr.end();t++)
{
auto monster=(*t);
if(monster->fsm->_currentState=="beingHit")
{
continue;
}
if(hero->getPosition().x>monster->getPosition().x)
{
monster->setScaleX(-1);
monster->boolstate->setScaleX(-1);
}
else
{
monster->setScaleX(1);
monster->boolstate->setScaleX(1);
}
if((distance(hero->getPosition(),monster->getPosition()))<500)
{
if((distance(hero->getPosition(),monster->getPosition()))<100)
{
monster->fsm->doEvent("attack1");
hero->stopAllActions();
hero->resumestate();
hero->currentblood-=monster->attck;
if(hero->currentblood<=0)
{
hero->fsm->doEvent("die");
scheduleOnce([this](float dt){
this->getParent()->getParent()->addChild(Interfactionlayer::create(402));
Director::getInstance()->pause();
}, 1, "gameover");
}
else {
hero->fsm->doEvent("beHit");
}
((Movehandler*) this->getParent()->getChildByTag(998))->updatedetal();
continue;
}
monster->fsm->doEvent("run");
movemonster(monster);
}
else
{
monster->fsm->doEvent("stop");
}
}
}
开发者ID:baokuanze,项目名称:RPG,代码行数:54,代码来源:battblegamebg.cpp
示例6: setScaleX
void Skin::setSkinData(const Node& var)
{
m_sSkinData = var;
setScaleX(m_sSkinData.scaleX);
setScaleY(m_sSkinData.scaleY);
setScaleX(m_sSkinData.scaleX);
setScaleY(m_sSkinData.scaleY);
setRotation(CC_RADIANS_TO_DEGREES(m_sSkinData.skewX));
setPosition(ccp(m_sSkinData.x, m_sSkinData.y));
m_tSkinTransform = nodeToParentTransform();
}
开发者ID:bo-jwolf,项目名称:Graduation,代码行数:14,代码来源:CSSkin.cpp
示例7: getAnimation
void WarriorNode::update_ui()
{
const std::string direction_str = _current_direction == up ? "B" :
(_current_direction == down ? "F" : "S");
const std::string state_str = _current_state == stand ? "stand" :
(_current_state == run ? "run" : "fight");
getAnimation()->play(direction_str + state_str);
if (_current_direction == left || _current_direction == right)
setScaleX(_current_direction == right ? -1.0f : 1.0f);
else
setScaleX(1.0f);
}
开发者ID:yubinyyy,项目名称:mota,代码行数:15,代码来源:Warrior.cpp
示例8: getPosition
void FDirSprite::chgDir(float dx, float dy)
{
const cocos2d::Vec2& pos = getPosition();
bool left = (m_curDir == FDIR_LEFT_UP || m_curDir == FDIR_LEFT_DOWN);
bool up = (m_curDir == FDIR_RIGHT_UP || m_curDir == FDIR_LEFT_UP);
if (pos.x > dx) {
left = true;
}
else if (pos.x < dx) {
left = false;
}
if (pos.y > dy) {
up = false;
}
else if (pos.y < dy) {
up = true;
}
int dir = left ? (up ? FDIR_LEFT_UP : FDIR_LEFT_DOWN) : (up ? FDIR_RIGHT_UP : FDIR_RIGHT_DOWN);
if (dir != m_curDir) {
m_curDir = dir;
setScaleX(left ? -1 : 1);
setSpriteFrame(m_lstFrames[up ? (m_frameNums + m_curIndex) : m_curIndex]);
}
}
开发者ID:zhs007,项目名称:porcupine,代码行数:29,代码来源:fdirsprite.cpp
示例9: init
bool GameOver::init(){
if(!Layer::init())
return false;
//定义背景
auto sprite = Sprite::create("background.jpg");
//float windowWidth=Director::getInstance()->getWinSize().width;
//float windowHeight=Director::getInstance()->getWinSize().height;
float imgWidth=sprite->getTextureRect().getMaxX();
float imgHeight=sprite->getTextureRect().getMaxY();
sprite->setScaleX(GAME_SCREEN_WIDTH/imgWidth);
sprite->setScaleY(GAME_SCREEN_HEIGHT/imgHeight);
sprite->setPosition(GAME_SCREEN_WIDTH/2,GAME_SCREEN_HEIGHT/2);
this->addChild(sprite, 0);
//定义标题
auto labelTitle=Label::createWithTTF("GAME OVER", "fonts/showg.ttf", FONT_SUPER_LARGE);
labelTitle->setPosition(Point(GAME_SCREEN_WIDTH/2,GAME_SCREEN_HEIGHT*3/4));
labelTitle->setColor(Color3B(238,149,114));
this->addChild(labelTitle);
//定义restart
auto labelRestart=Label::createWithTTF("Restart", "fonts/arial.ttf", FONT_SMALL);
labelRestart->setColor(Color3B(238,149,114));
auto menuItemLabel=MenuItemLabel::create(labelRestart,CC_CALLBACK_1(GameOver::restart,this));
menuItemLabel->setPosition(Point(GAME_SCREEN_WIDTH-labelRestart->getContentSize().width,GAME_SCREEN_HEIGHT*3/5));
auto menu=Menu::create(menuItemLabel,NULL);
menu->setPosition(Point::ZERO);
this->addChild(menu);
return true;
}
开发者ID:haoyangt,项目名称:Projects,代码行数:29,代码来源:GameOverScene.cpp
示例10: setEnabled
void UIWidget::copyProperties(UIWidget *widget)
{
setEnabled(widget->isEnabled());
setVisible(widget->isVisible());
setBright(widget->isBright());
setTouchEnabled(widget->isTouchEnabled());
m_bTouchPassedEnabled = false;
setZOrder(widget->getZOrder());
setUpdateEnabled(widget->isUpdateEnabled());
setTag(widget->getTag());
setName(widget->getName());
setActionTag(widget->getActionTag());
m_bIgnoreSize = widget->m_bIgnoreSize;
m_tSize = widget->m_tSize;
m_tCustomSize = widget->m_tCustomSize;
copySpecialProperties(widget);
m_eSizeType = widget->getSizeType();
m_tSizePercent = widget->m_tSizePercent;
m_ePositionType = widget->m_ePositionType;
m_tPositionPercent = widget->m_tPositionPercent;
setPosition(widget->getPosition());
setAnchorPoint(widget->getAnchorPoint());
setScaleX(widget->getScaleX());
setScaleY(widget->getScaleY());
setRotation(widget->getRotation());
setRotationX(widget->getRotationX());
setRotationY(widget->getRotationY());
setFlipX(widget->isFlipX());
setFlipY(widget->isFlipY());
setColor(widget->getColor());
setOpacity(widget->getOpacity());
setCascadeOpacityEnabled(widget->isCascadeOpacityEnabled());
setCascadeColorEnabled(widget->isCascadeColorEnabled());
onSizeChanged();
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:35,代码来源:UIWidget.cpp
示例11: CC_CALLBACK_1
bool QuitMenu::init()
{
if (!Layer::init())
{
//auto label = Label::createWithSystemFont("Hello World", "Arial", 96);
//label->setAnchorPoint(cocos2d::Vec2(0.0, 0.0));
//this->addChild(label, 1);
return false;
}
auto bg =
Sprite::create("MainMenuScreen/BackgroundTemp.jpeg");
auto areYouSureItem =
MenuItemImage::create("QuitScreen/AreYouSureText.png",
"QuitScreen/AreYouSureText.png");
auto yesItem =
MenuItemImage::create("QuitScreen/YesButton.png",
"QuitScreen/YesButton.png",
CC_CALLBACK_1(QuitMenu::menuCloseCallback, this));
auto noItem =
MenuItemImage::create("QuitScreen/NoButton.png",
"QuitScreen/NoButton.png",
CC_CALLBACK_1(QuitMenu::resume, this));
Size visibleSize = Director::getInstance()->getVisibleSize();
bg->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2));
bg->setScaleX(visibleSize.width / bg->getContentSize().width);
bg->setScaleY(visibleSize.height / bg->getContentSize().height);
auto menu = Menu::create(areYouSureItem, yesItem, noItem, NULL);
menu->alignItemsVerticallyWithPadding(visibleSize.height / 4);
this->addChild(bg);
this->addChild(menu);
return true;
}
开发者ID:TS64,项目名称:GamesDevicesProject1Android,代码行数:33,代码来源:QuitMenu.cpp
示例12: Value
bool GameNext::init()
{
//////////////////////////////
// 1. super init first
if (!Scene::init())
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////
if(game_round<=9)
{
gr_pic = "0" + Value(game_round).asString();
}else if(game_round>=10)
{
gr_pic = Value(game_round).asString();
}
if((game_level-1)<=9)
{
gl_pic = "0" + Value(game_level-1).asString();
}else if((game_level-1)>=10)
{
gl_pic = Value(game_level-1).asString();
}
//被弄成灰色的截图
auto ac = Sprite::create(picNext);
ac->setAnchorPoint(Vec2(0,0));
ac->setPosition(Vec2(0,0));
ac->setScaleX(visibleSize.width/ac->getTextureRect().getMaxX()); //设置精灵宽度缩放比例
ac->setScaleY(visibleSize.height/ac->getTextureRect().getMaxY());
this->addChild(ac,100);
//半透明层,在截图之上
LayerColor* layerColor = CCLayerColor::create();
layerColor->setColor(cocos2d::Color3B(0, 0, 0));
layerColor->setOpacity(150);
layerColor->setContentSize(Size(visibleSize.width, visibleSize.height));
this->addChild(layerColor,101);
//next小方块的背景
auto gameover = Sprite::create("setting/gamenext.png");
gameover->setPosition(Vec2(origin.x + visibleSize.width/2,origin.y + visibleSize.height/2));
this->addChild(gameover,102);
scheduleUpdate();
return true;
}
开发者ID:kimikimi911,项目名称:growup,代码行数:60,代码来源:GameNext.cpp
示例13: loadFromCache
bool PlanetSprite::init()
{
if(!Sprite3D::init())
return false;
//Loads the mesh from cache
loadFromCache(PLANET_MESH_MARS);
//Loads the texture
setTexture(PLANET_TEXTURE_MARS);
//Calculates a random rotation speed and Z axis inclination
int rotationSpeed = RandomHelper::random_int(1, 3);
unsigned int axisInclinitation = RandomHelper::random_int(-90, 90);
//Calculates a random sacale
float scale = RandomHelper::random_real(1.f, 3.f);
//Calculates a irregular scale
float scaleX = RandomHelper::random_real(1.0f, 1.25f) * scale;
float scaleY = RandomHelper::random_real(1.0f, 1.25f) * scale;
float scaleZ = RandomHelper::random_real(1.0f, 1.25f) * scale;
setScaleX(scaleX);
setScaleY(scaleY);
setScaleZ(scaleZ);
setRotation3D(Vec3(0, 0, axisInclinitation));
runAction(RepeatForever::create(RotateBy::create(rotationSpeed, Vec3(0, 360, 0))));
return true;
}
开发者ID:Skillath,项目名称:ET-Wars,代码行数:32,代码来源:PlanetSprite.cpp
示例14: init
bool UpgradeMenu::init()
{
if (!Layer::init())
{
return false;
}
CCSize s = CCDirector::sharedDirector()->getWinSize();
auto mySprite = Sprite::create("UpgradeScreen/tutorial.png");
mySprite->setScaleX((s.width / mySprite->getContentSize().width));
mySprite->setScaleY((s.height / mySprite->getContentSize().height));
// bottom left
mySprite->setAnchorPoint(cocos2d::Vec2(0, 0));
this->addChild(mySprite, -1);
auto mainMenuItem =
MenuItemImage::create("UpgradeScreen/Menu_Button.png",
"UpgradeScreen/Menu_Button(Click).png",
CC_CALLBACK_1(UpgradeMenu::activateMainMenuScene, this));
auto menu = Menu::create(mainMenuItem, NULL);
// Returns visible size of OpenGL window in points.
Size visibleSize = Director::getInstance()->getVisibleSize();
menu->setPosition(150, s.height - 100);
this->addChild(menu);
return true;
}
开发者ID:JohnKavanagh1050,项目名称:Bawse-Phighter-Android,代码行数:28,代码来源:UpgradeScene.cpp
示例15:
CoreElementBullet::CoreElementBullet(const std::string& armatureName, const std::string& effectArmatureName, float radian, float speed, const cocos2d::Vec2& position)
{
_speedX = std::cos(radian) * speed;
_speedY = -std::sin(radian) * speed;
_armature = CoreElementGame::instance->factory.buildArmature(armatureName);
_armatureDisplay = (dragonBones::CCArmatureDisplay*)_armature->getDisplay();
_armatureDisplay->setPosition(position);
_armatureDisplay->setRotation(radian * dragonBones::RADIAN_TO_ANGLE);
_armature->getAnimation().play("idle");
if (!effectArmatureName.empty())
{
_effect = CoreElementGame::instance->factory.buildArmature(effectArmatureName);
const auto effectDisplay = (dragonBones::CCArmatureDisplay*)_effect->getDisplay();
effectDisplay->setPosition(position);
effectDisplay->setRotation(radian * dragonBones::RADIAN_TO_ANGLE);
effectDisplay->setScaleX(cocos2d::random(1.f, 2.f));
effectDisplay->setScaleY(cocos2d::random(1.f, 1.5f));
if (cocos2d::random(0.f, 1.f) < 0.5f)
{
effectDisplay->setScaleY(effectDisplay->getScaleY());
}
_effect->getAnimation().play("idle");
dragonBones::WorldClock::clock.add(_effect);
CoreElementGame::instance->addChild(effectDisplay);
}
dragonBones::WorldClock::clock.add(_armature);
CoreElementGame::instance->addChild(_armatureDisplay);
}
开发者ID:machs,项目名称:DragonBonesCPP,代码行数:33,代码来源:CoreElement.cpp
示例16: rootPage
void PageManager::changeBackGround(const std::string &pic)
{
auto backLlayer = rootPage()->_backLayer;
if ( backLlayer )
{
backLlayer->removeAllChildren();
if ( pic.empty() )
{
// empty pic name will delete the background.
return;
}
auto background = CCSprite::create(pic.c_str());
if ( !background )
{
// invalid pic name will delete the background.
return;
}
auto size = background->getContentSize();
auto winSize = CocosWindow::size();
background->setScaleX(winSize.width / size.width);
background->setScaleY(winSize.height / size.height);
background->setPosition(CocosWindow::center());
backLlayer->addChild(background);
}
}
开发者ID:elloop,项目名称:cocos2d-x-cpp-demos-2.x,代码行数:26,代码来源:PageManager.cpp
示例17: schedule_selector
// on "init" you need to initialize your instance
bool SplashScene::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
//定时器设置停留2秒后自动跳转到主界面
this->scheduleOnce( schedule_selector( SplashScene::GoToMainMenuScene ), DISPLAY_TIME_SPLASH_SCENE );
auto backgroundSprite = Sprite::create( "splash.jpg" );
Size size = Director::getInstance()->getWinSize();
backgroundSprite->setPosition(Vec2(size.width / 2, size.height / 2));
float winw = size.width; //获取屏幕宽度
float winh = size.height;//获取屏幕高度
float spx = backgroundSprite->getTextureRect().getMaxX();
float spy = backgroundSprite->getTextureRect().getMaxY();
backgroundSprite->setScaleX(winw / spx); //设置精灵宽度缩放比例
backgroundSprite->setScaleY(winh / spy);
//backgroundSprite->setPosition( Point( visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y) );
this->addChild( backgroundSprite );
return true;
}
开发者ID:LINMouMouZiBo,项目名称:cocos-game,代码行数:34,代码来源:SplashScene.cpp
示例18: center
bool GuideScene::init()
{
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
cocos2d::Vec2 center((cocos2d::Director::getInstance()->getVisibleSize().width / 2 + cocos2d::Director::getInstance()->getVisibleOrigin().x), (cocos2d::Director::getInstance()->getVisibleSize().height / 2 + cocos2d::Director::getInstance()->getVisibleOrigin().y));
auto welcomePic=Sprite::create("Starter_bg.png");
welcomePic->setPosition(Point(visibleSize.width/2+origin.x, visibleSize.height/2+origin.y));
welcomePic->setScaleX(visibleSize.width/welcomePic->getContentSize().width);
welcomePic->setScaleY(visibleSize.height/welcomePic->getContentSize().height);
this->addChild(welcomePic);
auto menuItem = MenuItemImage::create("Exit (1).png", "Exit (2).png", CC_CALLBACK_1(GuideScene::goToMainMenu, this));
menuItem->setPosition(center.x, center.y - visibleSize.height*0.35);
auto menu = Menu::create(menuItem, NULL);
menu->setPosition(Point::ZERO);
this->addChild(menu);
Guide_move();
return true;
}
开发者ID:Noctiz-Jin,项目名称:Halloween-Candy-Rush-Night,代码行数:28,代码来源:Credits.cpp
示例19: playAnimationByname
void Rolelayer::playAnimationByname(Node *bs,std::string jsonfile,std::string filename,std::string animationName,bool isloop,bool isscal,Vec2 p){
auto armature =Armature::create(filename.c_str());
if(isloop==true){
armature->getAnimation()->play(animationName.c_str(),-1,1);
}
armature->removeFromParentAndCleanup(true);
armature->setPosition(p);
armature->setTag(100);
armature->setLocalZOrder(100);
bs->addChild(armature);
//xx_sly
if(getUnitTypeByArmatureName(filename) == unittype_Actor){
auto yinying_img=Sprite::create(hero_yingyin_img); //(hero_yingyin_img);
yinying_img->setAnchorPoint(Vec2(0.5,0));
yinying_img->setScaleX(1.5f);
yinying_img->setPosition(Vec2(p.x,-armature->getContentSize().height/2+40));
bs->addChild(yinying_img);
// xkongz.xx_action=armature;
// xkongz.time=0;
// xkongz.xxtime[0]=20;
// xkongz.xxtime[1]=1;
// xkongz.change=false;
}
else if(getUnitTypeByArmatureName(filename) == unittype_Pet){
auto yinying_img=Sprite::create(hero_yingyin_img); //(hero_yingyin_img);
yinying_img->setAnchorPoint(Vec2(0.5,0));
yinying_img->setPosition(Vec2(p.x,-armature->getContentSize().height/2+30));
bs->addChild(yinying_img);
}
else if(getUnitTypeByArmatureName(filename) == unittype_Magic){
armature->setScale(0.5f);
}
}
开发者ID:SongCF,项目名称:game-CoolRun,代码行数:34,代码来源:Rolelayer.cpp
示例20: CCLOG
void Stage1Scene::menuSubmitCallback(Ref* pSender)
{
currentAnswer = mAnswerBox->getText();
CCLOG("%s",currentAnswer.c_str());
if (currentAnswer != answer[questionIndex] ) {
pictureIndex++;
if (pictureIndex >= 5) {
CCLOG("fuck");
Director::getInstance()->replaceScene(MapScene::create());
}
}
else { // wining
UserDefault::getInstance()->setStringForKey(UserDefault::getInstance()->getStringForKey("CurrentCityName").c_str(), "win");
UserDefault::getInstance()->setIntegerForKey("CurrentCityNo",questionIndex + 1);
UserDefault::getInstance()->setStringForKey("CurrentCityName", __String::createWithFormat("city0%d", questionIndex + 1)->getCString());
Director::getInstance()->replaceScene(MapScene::create());
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin();
auto cluePicture = Sprite::create(__String::createWithFormat("%s%d.jpg", cluePictures[questionIndex].c_str(), pictureIndex)->getCString());
cluePicture->setPosition(Point(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y+visibleSize.height/5));
cluePicture->setScaleX(visibleSize.width / 2 / cluePicture->getContentSize().width);
cluePicture->setScaleY(visibleSize.height / 2 / cluePicture->getContentSize().height);
// add the sprite as a child to this layer
mStage1Layer->addChild(cluePicture);
currentAnswer = "sai";
}
开发者ID:K57CA-PMP,项目名称:SaveTheWorld,代码行数:29,代码来源:Stage1Scene.cpp
注:本文中的setScaleX函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论