void CCLineNode::draw() { const ccColor3B& tColor(getColor()); ccDrawColor4B(tColor.r, tColor.g, tColor.b, getOpacity()); CCPoint tOrigin(isIgnoreAnchorPointForPosition() ? CCPointZero : getAnchorPointInPoints()); ccDrawLine(tOrigin, ccpShift(tOrigin, getContentSize())); }
bool TiLayer::initWithTxml(const std::string& file) { if (!cocos2d::Layer::init()) { return false; } setAnchorPoint(cocos2d::Vec2::ANCHOR_MIDDLE); m_uiReader = tina::WidgetReader::create(file); m_uiReader->retain(); auto _rootWidget = m_uiReader->getRootWidget(); { addChild(_rootWidget); if (!_rootWidget->isIgnoreAnchorPointForPosition()) { _rootWidget->setPosition(_rootWidget->getAnchorPointInPoints()); } } setContentSize(_rootWidget->getContentSize()); if (m_uiReader != nullptr && m_uiReader->getRootWidget()) { foreachWidgetChildren(m_uiReader->getRootWidget()); } return true; }
bool BattleEntity::init() { m_vecAnimation.resize(ES_MAX); m_vecAnimation[ES_IDLE] = "Idle"; m_vecAnimation[ES_IDLE2] = "Idle"; m_vecAnimation[ES_RUN] = "Move"; m_vecAnimation[ES_WIN] = "Cheer"; m_vecAnimation[ES_FALIURE] = "failure"; m_vecAnimation[ES_ATTACK1] = "atk"; m_vecAnimation[ES_ATTACK2] = "atk"; m_vecAnimation[ES_SKILL1] = "atk2"; m_vecAnimation[ES_SKILL2] = "atk2"; m_vecAnimation[ES_HURT] = "Damaged"; m_vecAnimation[ES_DEAD] = "Death"; InitData(); m_pAnimationNode = CreateAnimation(); addChild(m_pAnimationNode); m_pAnimationNode->setPosition(getAnchorPointInPoints()); OnAnimationCreate(m_pAnimationNode); scheduleUpdate(); return true; }
cocos2d::AffineTransform GAFObject::GAF_CGAffineTransformCocosFormatFromFlashFormat(cocos2d::AffineTransform aTransform) { cocos2d::AffineTransform transform = aTransform; transform.b = -transform.b; transform.c = -transform.c; float flipMul = isFlippedY() ? -2 : 2; transform.ty = getAnchorPointInPoints().y * flipMul - transform.ty; return transform; }
bool BaseSprite::_isContainPoint( CCTouch *touch ) { CCPoint arPoint = getAnchorPointInPoints(); CCPoint point = convertTouchToNodeSpaceAR(touch); CCRect rect = boundingBox(); CCSize spriteSize = rect.size; CCRect spriteRect = CCRectMake(-arPoint.x,-arPoint.y,spriteSize.width,spriteSize.height); return spriteRect.containsPoint(point); }
void CCRectNode::draw() { const ccColor3B& tColor(getColor()); CCPoint tOrigin(isIgnoreAnchorPointForPosition() ? CCPointZero : getAnchorPointInPoints()); CCPoint tDestination(ccpShift(tOrigin, getContentSize())); if (m_bFill) { ccColor4F tColor4F(ccc4FFromccc3B(tColor)); tColor4F.a = getOpacity() / 255.0f; ccDrawSolidRect(tOrigin, tDestination, tColor4F); } else { ccDrawColor4B(tColor.r, tColor.g, tColor.b, getOpacity()); ccDrawRect(tOrigin, tDestination); } }
void CCEPixelNode::setFlipY(bool v) { bool old = m_flipY?1:0; m_flipY = v; if(old==(m_flipY?1:0))return; // flip float cy = getAnchorPointInPoints().y; ccePixelPart* pt = m_pPixels; while(pt!=NULL) { for(int i=0;i<pt->len;i++) { ccePixelInfo* p = pt->pixels+i; for(int j=0;j<4;j++) { p->square[j].y = cy + cy - p->square[j].y; } } pt = pt->next; } }
void CCEPixelNode::pixel(ccePixelInfo* info, ccePixelDef* def) { info->type = def->type; info->square[0].x = (GLfloat) def->x*m_size; info->square[0].y = (GLfloat) def->y*m_size; info->square[1].x = (GLfloat) (def->x+def->width)*m_size; info->square[1].y = info->square[0].y; info->square[2].x = info->square[0].x; info->square[2].y = (GLfloat) (def->y+def->height)*m_size; info->square[3].x = info->square[1].x; info->square[3].y = info->square[2].y; if(m_flipX || m_flipY) { CCPoint cp = getAnchorPointInPoints(); for(int j=0;j<4;j++) { if(m_flipX) { info->square[j].x = cp.x + cp.x - info->square[j].x; } if(m_flipY) { info->square[j].y = cp.y + cp.y - info->square[j].y; } } } for(int i=0;i<4;i++) { if(def->rgbColor) { info->color[i].r = m_tColor.r / 255.0f; info->color[i].g = m_tColor.g / 255.0f; info->color[i].b = m_tColor.b / 255.0f; } else { info->color[i].r = def->r / 255.0f; info->color[i].g = def->g / 255.0f; info->color[i].b = def->b / 255.0f; } info->color[i].a = m_cOpacity / 255.0f; } info->rgbColor = def->rgbColor; info->hide = def->hide; }
bool KeyInputTestScene::initSkin() { Vec2 origin = Director::getInstance()->getVisibleOrigin(); // add note skin(base) auto skin = Sprite::create("Default Skin(316_720).png"); //skin->setPosition(Vec2(158 + origin.x, visibleSize.height / 2 + origin.y)); skin->setAnchorPoint(Vec2(0, 0)); skin->setPosition(Vec2(origin.x, origin.y)); this->addChild(skin, 0, "skin"); // add note judge line auto skin_line = Sprite::create("Skin Line(720).png"); skin_line->setAnchorPoint(Vec2(0, 0)); skin_line->setPosition(Vec2(skin->getAnchorPointInPoints().x, skin->getAnchorPointInPoints().y + 114)); skin->addChild(skin_line, 1, "skin_line"); // add button image /* 1P SC*/ auto button_1p_sc = Sprite::create("Button SC.png"); button_1p_sc->setAnchorPoint(Vec2(0, 0)); skin->addChild(button_1p_sc, 1, "button_1p_sc"); button_1p_sc->setPosition(Vec2(skin->getAnchorPointInPoints().x, skin->getAnchorPointInPoints().y + 42)); /* 1P KEY 1 */ auto button_1p_1 = Sprite::create("Button Odd.png"); button_1p_1->setAnchorPoint(Vec2(0, 0)); button_1p_sc->addChild(button_1p_1, 1, "button_1p_1"); button_1p_1->setPosition(Vec2(button_1p_sc->getAnchorPointInPoints().x + 65, button_1p_sc->getAnchorPointInPoints().y)); /* 1P KEY 3 */ auto button_1p_3 = Sprite::create("Button Odd.png"); button_1p_3->setAnchorPoint(Vec2(0, 0)); button_1p_1->addChild(button_1p_3, 1, "button_1p_3"); button_1p_3->setPosition(Vec2(button_1p_sc->getAnchorPointInPoints().x + 72, 0)); /* 1P KEY 5 */ auto button_1p_5 = Sprite::create("Button Odd.png"); button_1p_5->setAnchorPoint(Vec2(0, 0)); button_1p_3->addChild(button_1p_5, 1, "button_1p_5"); button_1p_5->setPosition(Vec2(button_1p_sc->getAnchorPointInPoints().x + 72, 0)); /* 1P KEY 7 */ auto button_1p_7 = Sprite::create("Button Odd.png"); button_1p_7->setAnchorPoint(Vec2(0, 0)); button_1p_5->addChild(button_1p_7, 1, "button_1p_7"); button_1p_7->setPosition(Vec2(button_1p_sc->getAnchorPointInPoints().x + 72, 0)); /* 1P KEY 2 */ auto button_1p_2 = Sprite::create("Button Even.png"); button_1p_2->setAnchorPoint(Vec2(0, 0)); button_1p_1->addChild(button_1p_2, 1, "button_1p_2"); button_1p_2->setPosition(Vec2(button_1p_1->getAnchorPointInPoints().x + 38, button_1p_1->getAnchorPointInPoints().y + 16)); /* 1P KEY 4 */ auto button_1p_4 = Sprite::create("Button Even.png"); button_1p_4->setAnchorPoint(Vec2(0, 0)); button_1p_2->addChild(button_1p_4, 1, "button_1p_4"); button_1p_4->setPosition(Vec2(button_1p_2->getAnchorPointInPoints().x + 72, 0)); /* 1P KEY 6 */ auto button_1p_6 = Sprite::create("Button Even.png"); button_1p_6->setAnchorPoint(Vec2(0, 0)); button_1p_4->addChild(button_1p_6, 1, "button_1p_6"); button_1p_6->setPosition(Vec2(button_1p_4->getAnchorPointInPoints().x + 72, 0)); // add pressed note image /* 1P KEY 1 PRESSED */ auto button_1p_1_pressed = Sprite::create("Button Odd Pressed.png"); button_1p_1_pressed->setAnchorPoint(Vec2(0, 0)); skin->addChild(button_1p_1_pressed, 2, "button_1p_1_pressed"); button_1p_1_pressed->setPosition(Vec2( button_1p_sc->getPositionX() + 65, button_1p_sc->getPositionY())); button_1p_1_pressed->setVisible(false); /* 1P KEY 3 PRESSED */ auto button_1p_3_pressed = Sprite::create("Button Odd Pressed.png"); button_1p_3_pressed->setAnchorPoint(Vec2(0, 0)); skin->addChild(button_1p_3_pressed, 2, "button_1p_3_pressed"); button_1p_3_pressed->setPosition(Vec2( button_1p_1_pressed->getPositionX() + 72, button_1p_1_pressed->getPositionY())); button_1p_3_pressed->setVisible(false); /* 1P KEY 5 PRESSED */ auto button_1p_5_pressed = Sprite::create("Button Odd Pressed.png"); button_1p_5_pressed->setAnchorPoint(Vec2(0, 0)); skin->addChild(button_1p_5_pressed, 2, "button_1p_5_pressed"); button_1p_5_pressed->setPosition(Vec2( button_1p_3_pressed->getPositionX() + 72, button_1p_3_pressed->getPositionY())); button_1p_5_pressed->setVisible(false); /* 1P KEY 7 PRESSED */ auto button_1p_7_pressed = Sprite::create("Button Odd Pressed.png"); button_1p_7_pressed->setAnchorPoint(Vec2(0, 0)); skin->addChild(button_1p_7_pressed, 2, "button_1p_7_pressed"); button_1p_7_pressed->setPosition(Vec2( button_1p_5_pressed->getPositionX() + 72, button_1p_5_pressed->getPositionY())); button_1p_7_pressed->setVisible(false); /* 1P KEY 2 PRESSED */ auto button_1p_2_pressed = Sprite::create("Button Even Pressed.png"); button_1p_2_pressed->setAnchorPoint(Vec2(0, 0)); skin->addChild(button_1p_2_pressed, 2, "button_1p_2_pressed"); button_1p_2_pressed->setPosition(Vec2( button_1p_1_pressed->getPositionX() + 38, button_1p_1_pressed->getPositionY() + 16)); button_1p_2_pressed->setVisible(false); /* 1P KEY 4 PRESSED */ auto button_1p_4_pressed = Sprite::create("Button Even Pressed.png"); button_1p_4_pressed->setAnchorPoint(Vec2(0, 0)); skin->addChild(button_1p_4_pressed, 2, "button_1p_4_pressed"); button_1p_4_pressed->setPosition(Vec2( button_1p_2_pressed->getPositionX() + 72, button_1p_2_pressed->getPositionY())); button_1p_4_pressed->setVisible(false); /* 1P KEY 6 PRESSED */ auto button_1p_6_pressed = Sprite::create("Button Even Pressed.png"); button_1p_6_pressed->setAnchorPoint(Vec2(0, 0)); skin->addChild(button_1p_6_pressed, 2, "button_1p_6_pressed"); button_1p_6_pressed->setPosition(Vec2( button_1p_4_pressed->getPositionX() + 72, button_1p_4_pressed->getPositionY())); button_1p_6_pressed->setVisible(false); return true; }
// on "init" you need to initialize your instance bool RelayGameLayer::init() { ////////////////////////////// // 1. super init first if (!GridLayer::init()) { return false; } Size visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); _SetDefaultValues(); //----------------------------------------------------- // 背景 auto spriteBack = Sprite::create("MainBackAll.png"); if(spriteBack) { // add "canvas" splash screen" spriteBack->setScale( this->getContentSize().width / spriteBack->getContentSize().width, this->getContentSize().height / spriteBack->getContentSize().height); // position the sprite on the center of the screen spriteBack->setPosition( origin.x + visibleSize.width / 2.f + origin.x, origin.y + visibleSize.height / 2.f + origin.y); spriteBack->setName("Back"); // add the sprite as a child to this layer this->addChild(spriteBack, ZOrder::BACK); } //----------------------------------------------------- // キャンバス auto layerCanvas = LayerCanvas::create(); if (layerCanvas && layerCanvas->createSprite("canvas.png")) { this->addChild(layerCanvas, ZOrder::CANVAS, "Canvas"); layerCanvas->setPosition( origin + visibleSize / 2.f ); layerCanvas->setVisible(false); } //----------------------------------------------------- // テーマ発表用 auto spriteBoard = Sprite::create("BigBoard.png"); if (spriteBoard) { spriteBoard->setPosition( origin + visibleSize/ 2.f ); spriteBack->setVisible(true); // 非表示 this->addChild(spriteBoard, ZOrder::BIGBOARD, "BigBoard"); auto size = spriteBoard->getContentSize(); // 表示ラベル設定 余白 x:90*y:60 // 上 auto labelTop = Label::createWithSystemFont("描く順番と解答者の発表です", "GenShinGothic-Regular.ttf", calcFontSize(40.f)); if (labelTop) { // 中央揃え上揃え labelTop->setAlignment(TextHAlignment::CENTER, TextVAlignment::TOP); labelTop->setPosition( size.width / 2.f, size.height - labelTop->getContentSize().height/2.f - 60.f ); spriteBoard->addChild(labelTop, 0, "TopLabel"); } // 中央 auto labelMiddle = Label::createWithSystemFont("", "GenShinGothic-Medium.ttf", calcFontSize(80.f)); labelMiddle->setName("MiddleLabel"); auto itemLabel = MenuItemLabel::create(labelMiddle, [this](Ref* pSender){ // 検索窓開く std::stringstream url; url << "https://www.google.co.jp/search?tbm=isch&q=" << m_nowTheme.theme; Application::getInstance()->openURL(url.str().c_str()); }); if (itemLabel) { m_pMiddleLabel = itemLabel; // 始めのうちは反応なし m_pMiddleLabel->setEnabled(false); // 中央揃え中央揃え labelMiddle->setAlignment(TextHAlignment::CENTER, TextVAlignment::BOTTOM); labelMiddle->setColor(Color3B(250, 210, 10)); m_pMiddleLabel->setColor(Color3B(250, 210, 10)); labelMiddle->setDimensions(size.width - 90, 0); m_pMiddleLabel->setName("ItemMiddleLabel"); auto menu = Menu::create(m_pMiddleLabel, nullptr); menu->setPosition( size / 2.f ); spriteBoard->addChild(menu, 0, "MenuMiddleLabel"); } // 下 auto labelBottom = Label::createWithSystemFont("1人目の人から順に\n画面をタッチしてください", "GenShinGothic-Regular.ttf", calcFontSize(37.f)); if (labelBottom) { // 中央揃え下揃え labelBottom->setAlignment(TextHAlignment::CENTER, TextVAlignment::BOTTOM); labelBottom->setAnchorPoint(Vec2(0.5f, 0.0f)); labelBottom->setPosition( size.width / 2.f, labelBottom->getContentSize().height / 2.f + 60.f ); spriteBoard->addChild(labelBottom, 0, "BottomLabel"); } } //----------------------------------------------------- // ラベル用 auto spriteSmallBoard = Sprite::create("board.png"); if (spriteSmallBoard) { spriteSmallBoard->setPosition( origin.x + visibleSize.width / 2.f, origin.y + visibleSize.height - spriteSmallBoard->getContentSize().height / 2.f ); this->addChild(spriteSmallBoard, ZOrder::TOPBOARD, "SmallBoard"); } //----------------------------------------------------- // ラベル設定 // アナウンス auto label = Label::createWithSystemFont(" ", "GenShinGothic-Medium.ttf", calcFontSize(30.f)); { label->setColor(Color3B(250, 250, 250)); // 白文字 label->enableOutline(Color4B::BLACK, 3); // 黒枠線 label->setHorizontalAlignment(TextHAlignment::CENTER); spriteSmallBoard->addChild(label, 10, "Label"); label->setPosition(spriteSmallBoard->getAnchorPointInPoints()); m_pLabel = label; // キャッシュ } //----------------------------------------------------- //----------------------------------------------------- // ボタン auto nextButton = MenuItemImage::create("button.png", "button2.png", [this](Ref* pSender) { if (FlowPhase::ANSWERED == m_flowPhase) { // タイトルへ dynamic_cast<SceneAtelierMain*>(this->getParent()->getParent())->toTitle(); } else { // 全消去 m_touchPoints[m_nowPage].clear(); m_pDrawNode->clear(); } }); if (nextButton) { m_pNextButton = nextButton; nextButton->setName("NextButton"); // ボタン非表示 //nextButton->setVisible(false); auto size = nextButton->getContentSize(); nextButton->setPosition( origin.x + visibleSize.width - size.width / 2.f, origin.y + size.height / 2.f); auto label = Label::createWithSystemFont("全消去", "GenShinGothic-Medium.ttf", calcFontSize(20.f)); if (label) { m_pButtonLabel = label; label->setPosition(nextButton->getContentSize() / 2.f); label->setHorizontalAlignment(TextHAlignment::CENTER); // ラベル非表示 //label->setVisible(false); label->setColor(Color3B(5, 5, 5)); nextButton->addChild(label, ZOrder::NEXTBUTTONLABEL, "ButtonLabel"); } } auto menuButtons = Menu::create(nextButton, nullptr); if (menuButtons) { menuButtons->setPosition(Vec2::ZERO); menuButtons->setVisible(false); this->addChild(menuButtons, ZOrder::MENUBUTTONS, "MenuButtons"); } //----------------------------------------------------- // 前後ボタン // 前 auto itemBack = MenuItemImage::create("BackButton.png", "BackButton2.png", [this](Ref* pSender){ auto button = dynamic_cast<MenuItemImage*>(pSender); if (0 < m_nowPage) { // 戻るよ! auto oldCanvas = this->getChildByName("Canvas"); if (!oldCanvas) oldCanvas = this->getChildByName("Canvas" + std::to_string(m_nowPage)); --m_nowPage; std::stringstream ss; ss << "Canvas" << m_nowPage; auto layerCanvas = this->getChildByName(ss.str()); layerCanvas->setLocalZOrder(oldCanvas->getLocalZOrder() + 1); auto drawNode = layerCanvas->getChildByName<DrawNode*>("DrawNode"); layerCanvas->setVisible(true); layerCanvas->runAction( Sequence::create( ReverseTime::create(PageTurn3D::create(0.5f, Size(24.f, 32.f))), CallFunc::create([this, layerCanvas, drawNode](){ // キャンバスの入れ替え //-------------------------- // DrawNode入れ替え m_pDrawNode = drawNode; //-------------------------- }), nullptr ) ); if (0 == m_nowPage) { // もう戻れないよ! button->setVisible(false); } button->getParent()->getChildByName("LastNextButton")->setVisible(true); } }); { itemBack->setName("LastBackButton"); } auto itemNext = MenuItemImage::create("NextButton.png", "NextButton2.png", [this](Ref* pSender){ auto button = dynamic_cast<MenuItemImage*>(pSender); const auto maxPage = m_touchPoints.size() - 1; if (maxPage > m_nowPage) { // 進むよ! auto oldCanvas = this->getChildByName("Canvas"); if (!oldCanvas) oldCanvas = this->getChildByName("Canvas" + std::to_string(m_nowPage)); ++m_nowPage; std::stringstream ss; ss << "Canvas" << m_nowPage; auto layerCanvas = this->getChildByName(ss.str()); layerCanvas->setLocalZOrder(oldCanvas->getLocalZOrder() - 1); auto drawNode = layerCanvas->getChildByName<DrawNode*>("DrawNode"); layerCanvas->setVisible(true); oldCanvas->runAction( Sequence::create( PageTurn3D::create(0.5f, Size(24.f, 32.f)), CallFunc::create([this, layerCanvas, drawNode](){ // キャンバスの入れ替え //-------------------------- // DrawNode入れ替え m_pDrawNode = drawNode; //-------------------------- }), nullptr ) ); if (maxPage == m_nowPage) { // もう進めないよ! button->setVisible(false); } button->getParent()->getChildByName("LastBackButton")->setVisible(true); } }); { itemNext->setName("LastNextButton"); itemNext->setVisible(false); } auto menuLastButtons = Menu::create(itemBack, itemNext, nullptr); { // 縦一列,間隔 const float padding = 10.f; menuLastButtons->alignItemsVerticallyWithPadding(padding); // 非表示 menuLastButtons->setVisible(false); auto canvas = layerCanvas->getSprite(); Vec2 leftBottom = canvas->convertToWorldSpace(Vec2::ZERO); auto size = itemBack->getContentSize(); menuLastButtons->setPosition(leftBottom.x / 2.f, leftBottom.y + size.height + padding / 2.f); this->addChild(menuLastButtons, ZOrder::MENULASTBUTTONS, "MenuLastButtons"); } //----------------------------------------------------- m_pDrawNode = DrawNode::create(); { m_pDrawNode->setAnchorPoint(Vec2::ZERO); auto canvas = layerCanvas->getSprite(); //layerCanvas->addChild(m_pDrawNode, 1); m_pDrawNode->setPosition( -(layerCanvas->getPositionX() - layerCanvas->getAnchorPoint().x*layerCanvas->getContentSize().width ), -(layerCanvas->getPositionY() - layerCanvas->getAnchorPoint().y*layerCanvas->getContentSize().height) ); canvas->addChild(m_pDrawNode, 1, "DrawNode"); } //----------------------------------------------------- // 描きすぎレイヤー auto layerTouch = Layer::create(); { layerTouch->setVisible(false); auto sprite = Sprite::create(); // 背景用 sprite->setTextureRect(Rect(0, 0, visibleSize.width, visibleSize.height)); sprite->setPosition(visibleSize / 2.f); sprite->setColor(Color3B::BLACK); sprite->setOpacity(192); layerTouch->addChild(sprite, 0); this->addChild(layerTouch, ZOrder::MOST_FRONT, "OverTouchLayer"); auto label = Label::createWithSystemFont("一人の持ち時間を使い果たしました\n" "\n次の人に回してタッチしてください\n", "GenShinGothic-Medium.ttf", calcFontSize(40.f)); { label->setPosition(layerTouch->getContentSize() / 2.f); label->setAlignment(TextHAlignment::CENTER, TextVAlignment::CENTER); label->setColor(Color3B(250, 250, 15)); layerTouch->addChild(label, 10, "Label"); } auto listener = EventListenerTouchOneByOne::create(); listener->setSwallowTouches(false); listener->onTouchBegan = [this, layerTouch](Touch* touch, Event* event){ if (layerTouch->isVisible()) { return true; } return false; }; listener->onTouchEnded = [this, layerTouch](Touch* touch, Event* event){ //layerTouch->setVisible(false); //m_pListener->setSwallowTouches(false); // 描きすぎレイヤー非表示 this->_SetOverTouchLayerVisible(false); if (m_nowPage >= m_playerNum - 2) { // 全員描いた場合 // キャンバスめくらない m_flowPhase = FlowPhase::JUDGE; // 解答ボックス出現 auto visibleSize = Director::getInstance()->getVisibleSize(); m_pEditBox->runAction( Sequence::create( CallFunc::create([this]{ m_pEditBox->setEnabled(false); }), EaseBackOut::create( MoveTo::create(0.5f, Vec2(visibleSize.width / 2.f, m_pEditBox->getPositionY() ) // 画面中央まで ) ), CallFunc::create([this]{ m_pEditBox->setEnabled(true); }), nullptr ) ); // 全消去無効化 m_pNextButton->setVisible(false); // ラベルの設定 m_pLabel->setString("テーマを答えてください"); } else { // 前の人の絵を見せる m_flowPhase = FlowPhase::SHOW; m_pLabel->setString("見終わったらタッチして描き始めてください"); } // 全員描いた場合 //if (m_nowPage >= m_playerNum - 1) //{ // // フェーズ // m_flowPhase = FlowPhase::JUDGE; // // // 解答ボックス出現 // auto visibleSize = Director::getInstance()->getVisibleSize(); // m_pEditBox->runAction( // Sequence::create( // CallFunc::create([this]{ m_pEditBox->setEnabled(false); }), // EaseBackOut::create( // MoveTo::create(0.5f, // Vec2(visibleSize.width / 2.f, // m_pEditBox->getPositionY() // ) // 画面中央まで // ) // ), // CallFunc::create([this]{ m_pEditBox->setEnabled(true); }), // nullptr // ) // ); // // // ラベルの設定 // m_pLabel->setString("テーマを答えてください"); // // //} }; this->_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, layerTouch); m_pListener = listener; } //----------------------------------------------------- // 解答入力ボックス m_pEditBox = EditBox::create(spriteSmallBoard->getContentSize(), Scale9Sprite::create("board.png")); { // box auto size = m_pEditBox->getContentSize(); m_pEditBox->setPreferredSize(spriteSmallBoard->getContentSize()); m_pEditBox->setAnchorPoint(Vec2::ANCHOR_MIDDLE); m_pEditBox->setPosition(Vec2( origin.x + visibleSize.width + size.width / 2.f, origin.y + size.height / 2.f)); //m_pEditBox->setPosition(Vec2( // origin.x + visibleSize.width / 2.f, // origin.y + size.height / 2.f)); // 内部ラベル m_pEditBox->setFontName("GenShinGothic-Regular.ttf"); // ファミリー m_pEditBox->setFontSize(static_cast<int>(calcFontSize(25.f))); // サイズ m_pEditBox->setFontColor(Color3B(250, 250, 250)); // 色 m_pEditBox->getLabel()->setAnchorPoint(Vec2::ANCHOR_MIDDLE); m_pEditBox->getLabel()->setPosition(spriteSmallBoard->getContentSize() / 2.f); // 初期ラベル m_pEditBox->setPlaceHolder("ここをタッチして解答 (全てひらがなで、数字は半角で入力)"); // 例等初期値(入力時に消える) m_pEditBox->setPlaceholderFontColor(Color3B(5, 5, 5)); m_pEditBox->getPlaceHolderLabel()->setAnchorPoint(Vec2::ANCHOR_MIDDLE); m_pEditBox->getPlaceHolderLabel()->setPosition(spriteSmallBoard->getContentSize() / 2.f); // Box自体の設定 m_pEditBox->setMaxLength(20); // 文字数 m_pEditBox->setReturnType(EditBox::KeyboardReturnType::DEFAULT); // Returnキーが押された時 m_pEditBox->setInputMode(EditBox::InputMode::SINGLE_LINE); // 1行,自由文字列 // メソッド m_pEditBox->setDelegate(this); this->addChild(m_pEditBox, ZOrder::BOX, "EditBox"); } //----------------------------------------------------- // 間違え auto spriteCrossCanvas = Sprite::create("CrossCanvas.png"); { spriteCrossCanvas->setPosition(visibleSize / 2.f); spriteCrossCanvas->setVisible(false); this->addChild(spriteCrossCanvas, ZOrder::MOST_FRONT, "CrossCanvas"); } //----------------------------------------------------- // 正解 auto spriteCircleCanvas = Sprite::create("CircleCanvas.png"); { spriteCircleCanvas->setPosition(visibleSize / 2.f); spriteCircleCanvas->setVisible(false); this->addChild(spriteCircleCanvas, ZOrder::MOST_FRONT, "CircleCanvas"); } return true; }
void BattleEntityPlayer::OnAnimationCreate(EntityAnimation* pNode) { pNode->setPosition(ccp(getAnchorPointInPoints().x, getAnchorPointInPoints().y - getContentSize().height*0.5)); }