• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setWidth函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中setWidth函数的典型用法代码示例。如果您正苦于以下问题:C++ setWidth函数的具体用法?C++ setWidth怎么用?C++ setWidth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setWidth函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: dlg

// -----------------------------------------------------------------------------
// Static function to check if an archive has sufficient texture related
// entries, and if not, prompts the user to either create or import them.
// Returns true if the entries exist, false otherwise
// -----------------------------------------------------------------------------
bool TextureXEditor::setupTextureEntries(Archive* archive)
{
	using Format = TextureXList::Format;

	// Check any archive was given
	if (!archive)
		return false;

	// Search archive for any ZDoom TEXTURES entries
	Archive::SearchOptions options;
	options.match_type = EntryType::fromId("zdtextures");
	auto entry_tx      = archive->findFirst(options); // Find any TEXTURES entry

	// If it's found, we're done
	if (entry_tx)
		return true;


	// Search archive for any texture-related entries
	options.match_type = EntryType::fromId("texturex");
	entry_tx           = archive->findFirst(options); // Find any TEXTUREx entry
	options.match_type = EntryType::fromId("pnames");
	auto entry_pnames  = archive->findFirst(options); // Find any PNAMES entry

	// If both exist, we're done
	if (entry_tx && entry_pnames)
		return true;

	// Todo: accept entry_tx without pnames if the textures are in Jaguar mode

	// If no TEXTUREx entry exists
	if (!entry_tx)
	{
		// No TEXTUREx entries found, so ask if the user wishes to create one
		wxMessageDialog dlg(
			nullptr,
			"The archive does not contain any texture definitions (TEXTURE1/2 or TEXTURES). "
			"Do you wish to create or import a texture definition list?",
			"No Texture Definitions Found",
			wxYES_NO);

		if (dlg.ShowModal() == wxID_YES)
		{
			CreateTextureXDialog ctxd(nullptr);

			while (true)
			{
				// Check if cancelled
				if (ctxd.ShowModal() == wxID_CANCEL)
					return false;

				if (ctxd.createNewSelected())
				{
					// User selected to create a new TEXTUREx list
					ArchiveEntry* texturex = nullptr;

					// Doom or Strife TEXTUREx
					if (ctxd.getSelectedFormat() == Format::Normal || ctxd.getSelectedFormat() == Format::Strife11)
					{
						// Create texture list
						TextureXList txlist;
						txlist.setFormat(ctxd.getSelectedFormat());

						// Create patch table
						PatchTable ptt;

						// Create dummy patch
						auto dpatch = App::archiveManager().programResourceArchive()->entryAtPath("s3dummy.lmp");
						archive->addEntry(dpatch, "patches", true);
						ptt.addPatch("S3DUMMY");

						// Create dummy texture
						auto dummytex = std::make_unique<CTexture>();
						dummytex->setName("S3DUMMY");
						dummytex->addPatch("S3DUMMY", 0, 0);
						dummytex->setWidth(128);
						dummytex->setHeight(128);
						dummytex->setScale({ 0., 0. });

						// Add dummy texture to list
						// (this serves two purposes - supplies the special 'invalid' texture by default,
						//   and allows the texturex format to be detected)
						txlist.addTexture(std::move(dummytex));

						// Add empty PNAMES entry to archive
						entry_pnames = archive->addNewEntry("PNAMES");
						ptt.writePNAMES(entry_pnames);
						entry_pnames->setType(EntryType::fromId("pnames"));
						entry_pnames->setExtensionByType();

						// Add empty TEXTURE1 entry to archive
						texturex = archive->addNewEntry("TEXTURE1");
						txlist.writeTEXTUREXData(texturex, ptt);
						texturex->setType(EntryType::fromId("texturex"));
						texturex->setExtensionByType();
//.........这里部分代码省略.........
开发者ID:sirjuddington,项目名称:SLADE,代码行数:101,代码来源:TextureXEditor.cpp


示例2: getWidth

void Block::switchWidthAndHeight(void) {
	int temp = getWidth();
	setWidth(getHeight());
	setHeight(temp);
}
开发者ID:Gnash,项目名称:allegris,代码行数:5,代码来源:Block.cpp


示例3: setWidth

void VideoPlayer::parse(QVariantMap qMap)
{
	setWidth(qMap["width"].toInt());
	setEmbedCode(qMap["embed_code"].toString());
}
开发者ID:ekke,项目名称:tumblr,代码行数:5,代码来源:VideoPlayer.cpp


示例4: Widget

WidgetToggle::WidgetToggle(std::string name, bool initState) : Widget(),state(initState), name(name), listener(NULL) {
	setListenToMouse(true);
	setWidth(1);
	setHeight(1);

}
开发者ID:dwarfofdawn,项目名称:Minion_Game,代码行数:6,代码来源:WidgetToggle.cpp


示例5: setWidth

 void Button::adjustSize()
 {
     setWidth(getFont()->getWidth(mCaption) + 2*mSpacing);
     setHeight(getFont()->getHeight() + 2*mSpacing);
 }
开发者ID:512400330,项目名称:osgRecipes,代码行数:5,代码来源:button.cpp


示例6: setFullscreen

        void Movie::init()
        {
            if (_initialized) return;
            State::init();

            setFullscreen(true);
            setModal(true);

            Game::getInstance()->mouse()->pushState(Input::Mouse::Cursor::NONE);
            auto renderer = Game::getInstance()->renderer();
            setPosition((renderer->size() - Point(640, 320)) / 2);

            auto lst = ResourceManager::getInstance()->lstFileType("data/movies.lst");
            std::string movie = "art/cuts/" + lst->strings()->at(_id);

            auto cfglst = ResourceManager::getInstance()->lstFileType("data/moviecfgs.lst");
            std::string moviecfgfile = "art/cuts/" + cfglst->strings()->at(_id);
            _effects.push_back({0,1, 0, 0, 0, 1});

            if (cfglst->strings()->at(_id)!="reserved.cfg")
            {
                auto moviecfg = ResourceManager::getInstance()->datFileItem(moviecfgfile);
                //parse ini
                moviecfg->setPosition(0);
                std::istream str(moviecfg);
                auto inifile = new Ini::Parser(str);
                auto ini = inifile->parse();
                int total_effects = ini->section("info")->propertyInt("total_effects",0);
                auto effect_frames = ini->section("info")->propertyArray("effect_frames");
                for (int i =0;i<total_effects;i++)
                {
                    unsigned int effect_frame = effect_frames.at(i).intValue();
                    std::string effect_section = effect_frames.at(i).value();
                    int dir = (ini->section(effect_section)->propertyString("fade_type","in") == "in" ? -1 : 1);
                    int steps = ini->section(effect_section)->propertyInt("fade_steps",0);
                    auto colors = ini->section(effect_section)->propertyArray("fade_color");
                    int r = colors[0].intValue()*4;
                    int g = colors[1].intValue()*4;
                    int b = colors[2].intValue()*4;
                    _effects.push_back({effect_frame, dir, r, g, b, steps/15*1000});
                }
            }
            else
            {
                _effects.push_back({1,-1, 0, 0, 0, 1});
            }

            auto sublst = ResourceManager::getInstance()->lstFileType("data/subtitles.lst");
            std::string subfile = "text/english/cuts/" + sublst->strings()->at(_id);

            if (sublst->strings()->at(_id)!="reserved.sve")
            {
                _subs = ResourceManager::getInstance()->sveFileType(subfile);
                if (_subs) _hasSubs = true;
            }
            addUI("movie", new UI::MvePlayer(ResourceManager::getInstance()->mveFileType(movie)));

            auto font0_ffffffff = ResourceManager::getInstance()->font("font1.aaf");
            auto subLabel = new UI::TextArea("", 0, 320+35);

            subLabel->setFont(font0_ffffffff, {0xFF, 0xFF, 0xFF, 0xFF});
            subLabel->setWidth(640);
            subLabel->setHorizontalAlign(UI::TextArea::HorizontalAlign::CENTER);
            addUI("subs",subLabel);

            if (_hasSubs)
                _nextSubLine = _subs->getSubLine(0);
            else
                _nextSubLine = std::pair<int,std::string>(999999,"");
        }
开发者ID:CynicRus,项目名称:falltergeist,代码行数:70,代码来源:Movie.cpp


示例7: GetPageSize

	QSize TextDocumentAdapter::GetPageSize (int) const
	{
		auto size = Doc_->pageSize ();
		size.setWidth (std::ceil (size.width ()));
		return size.toSize ();
	}
开发者ID:SboichakovDmitriy,项目名称:leechcraft,代码行数:6,代码来源:textdocumentadapter.cpp


示例8: getFont

void BrowserBox::addRow(const std::string &row)
{
    std::string tmp = row;
    std::string newRow;
    BROWSER_LINK bLink;
    std::string::size_type idx1, idx2, idx3;
    gcn::Font *font = getFont();

    // Use links and user defined colors
    if (mUseLinksAndUserColors)
    {
        // Check for links in format "@@link|[email protected]@"
        idx1 = tmp.find("@@");
        while (idx1 != std::string::npos)
        {
            idx2 = tmp.find("|", idx1);
            idx3 = tmp.find("@@", idx2);

            if (idx2 == std::string::npos || idx3 == std::string::npos)
                break;
            bLink.link = tmp.substr(idx1 + 2, idx2 - (idx1 + 2));
            bLink.caption = tmp.substr(idx2 + 1, idx3 - (idx2 + 1));
            bLink.y1 = mTextRows.size() * font->getHeight();
            bLink.y2 = bLink.y1 + font->getHeight();

            newRow += tmp.substr(0, idx1);

            std::string tmp2 = newRow;
            idx1 = tmp2.find("##");
            while (idx1 != std::string::npos)
            {
                tmp2.erase(idx1, 3);
                idx1 = tmp2.find("##");
            }
            bLink.x1 = font->getWidth(tmp2) - 1;
            bLink.x2 = bLink.x1 + font->getWidth(bLink.caption) + 1;

            mLinks.push_back(bLink);

            newRow += "##<" + bLink.caption;

            tmp.erase(0, idx3 + 2);
            if (!tmp.empty())
            {
                newRow += "##>";
            }
            idx1 = tmp.find("@@");
        }

        newRow += tmp;
    }
    // Don't use links and user defined colors
    else
    {
        newRow = row;
    }

    mTextRows.push_back(newRow);

    //discard older rows when a row limit has been set
    if (mMaxRows > 0)
    {
        while (mTextRows.size() > mMaxRows)
        {
            mTextRows.pop_front();
            for (unsigned int i = 0; i < mLinks.size(); i++)
            {
                mLinks[i].y1 -= font->getHeight();
                mLinks[i].y2 -= font->getHeight();

                if (mLinks[i].y1 < 0)
                    mLinks.erase(mLinks.begin() + i);
            }
        }
    }

    // Auto size mode
    if (mMode == AUTO_SIZE)
    {
        std::string plain = newRow;
        for (idx1 = plain.find("##"); idx1 != std::string::npos; idx1 = plain.find("##"))
            plain.erase(idx1, 3);

        // Adjust the BrowserBox size
        int w = font->getWidth(plain);
        if (w > getWidth())
            setWidth(w);
    }

    if (mMode == AUTO_WRAP)
    {
        unsigned int y = 0;
        unsigned int nextChar;
        const char *hyphen = "~";
        int hyphenWidth = font->getWidth(hyphen);
        int x = 0;

        for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); i++)
        {
            std::string row = *i;
//.........这里部分代码省略.........
开发者ID:kai62656,项目名称:manabot,代码行数:101,代码来源:browserbox.cpp


示例9: setWidth

/*!
  Sets the size of the rectangle to size.
  Changes x2 and y2 only.
*/
void QwtDoubleRect::setSize(const QwtDoubleSize &size)
{
    setWidth(size.width());
    setHeight(size.height());
}
开发者ID:luisMbedder,项目名称:SpectrumScan,代码行数:9,代码来源:qwt_double_rect.cpp


示例10: setWidth

void Image::setSize(Size size) {
	setWidth(size.getWidth());
	setHeight(size.getHeight());
}
开发者ID:DeadNight,项目名称:robotics,代码行数:4,代码来源:Image.cpp


示例11: setWidth

Shape::Shape(int width, int height){
    setWidth(width);
    setHeight(height);
}
开发者ID:Soichi888,项目名称:ITDCanadaCPP,代码行数:4,代码来源:class21Shape.cpp


示例12: setPosition

void FFContainer::setDimension(const gcn::Rectangle &dimension)
{
    setPosition(dimension.x, dimension.y);
    setWidth(dimension.width);
    setHeight(dimension.height);
}
开发者ID:RobertoMalatesta,项目名称:guisan,代码行数:6,代码来源:ffcontainer.cpp


示例13: setWidth

void SpriteSheet::updateSizeInfo()
{
    m_frameWidth = m_pixMap->width() / m_frames;
    setWidth(m_frameWidth);
    setHeight(m_pixMap->height());
}
开发者ID:navrocky,项目名称:Bacon2D,代码行数:6,代码来源:spritesheet.cpp


示例14: prePaint

void ExploreLiveView::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget * widget)
{
    if(!isReady) return;

	prePaint(painter);

	postPaint(painter);

	auto glwidget = (Viewer*)widget;
    if (glwidget && meshes.size())
	{
		QRectF parentRect = parentItem()->sceneBoundingRect();

        if (isCacheImage && cachedImage.isNull())
        {
            QOpenGLContext context;
            context.setShareContext(glwidget->context());
            context.setFormat(glwidget->format());
            context.create();

            QOffscreenSurface m_offscreenSurface;
            m_offscreenSurface.setFormat(context.format());
            m_offscreenSurface.create();

            context.makeCurrent(&m_offscreenSurface);

            QOpenGLFramebufferObjectFormat fboformat;
            fboformat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
            QOpenGLFramebufferObject renderFbo(cacheImageSize*1.5, cacheImageSize, fboformat);
            renderFbo.bind();

            glwidget->glEnable(GL_DEPTH_TEST);
            glwidget->glEnable(GL_BLEND);
            glwidget->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
            glwidget->glCullFace(GL_BACK);

            glwidget->glClearColor(0,0,0,0);
            glwidget->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
            glwidget->glViewport(0, 0, cacheImageSize*1.5, cacheImageSize);

	// XXX Fix
            // glwidget->glPointSize(10);	

            // Draw aux meshes
            for (auto mesh : meshes)
            {
                if (mesh.isPoints)
                    glwidget->drawOrientedPoints(mesh.points, mesh.normals, mesh.color, glwidget->pvm);
                else
                    glwidget->drawTriangles(mesh.color, mesh.points, mesh.normals, glwidget->pvm);
            }

            glwidget->glDisable(GL_DEPTH_TEST);
            glwidget->glFlush();

            renderFbo.release();

            cachedImage = renderFbo.toImage();
            isReady = true;

            // Thanks for sharing!
            glwidget->makeCurrent();
        }

        // Draw as image
        if(isCacheImage)
        {
            int w = shapeRect.width();
            painter->drawImage(w * -0.5, w * -0.5, cachedImage.scaledToWidth(w));
        }

        if(!isCacheImage)
        {
            auto r = shapeRect;

            // scale view
            double s = 1.5;
            r.setWidth(r.width() * s);
            r.setHeight(r.height() * s);

            r.moveCenter(this->mapToScene(boundingRect().center()));

            painter->beginNativePainting();

            auto v = scene()->views().first();
            QPoint viewDelta = v->mapFromScene(r.topLeft());
            if (viewDelta.manhattanLength() > 5) r.moveTopLeft(viewDelta);

            auto camera = ExploreProcess::defaultCamera(document->extent().length());

            glwidget->eyePos = camera.first;
            glwidget->pvm = camera.second;
            glwidget->glViewport(r.left(), v->height() - r.height() - r.top(), r.width(), r.height());

            // Clipping OpenGL
            glwidget->glEnable(GL_SCISSOR_TEST);
            glwidget->glScissor(parentRect.x(), v->height() - parentRect.height() - parentRect.top(), parentRect.width(), parentRect.height());

            glwidget->glClear(GL_DEPTH_BUFFER_BIT);

//.........这里部分代码省略.........
开发者ID:gideonmay,项目名称:TopoBlender,代码行数:101,代码来源:ExploreLiveView.cpp


示例15: checkMemoryAllocation


//.........这里部分代码省略.........
            continue;
        }
        else if (character == UNICODE_SPACE) // space
        {
            // Just leave a gap, no tris
            left += mSpaceWidth;
            // Also reduce tri count
            mRenderOp.vertexData->vertexCount -= 6;
            continue;
        }

        Real horiz_height = mpFont->getGlyphAspectRatio(character) * mViewportAspectCoef ;
        const Font::UVRect& uvRect = mpFont->getGlyphTexCoords(character);

        // each vert is (x, y, z, u, v)
        //-------------------------------------------------------------------------------------
        // First tri
        //
        // Upper left
        *pVert++ = left;
        *pVert++ = top;
        *pVert++ = -1.0;
        *pVert++ = uvRect.left;
        *pVert++ = uvRect.top;

        top -= mCharHeight * 2.0f;

        // Bottom left
        *pVert++ = left;
        *pVert++ = top;
        *pVert++ = -1.0;
        *pVert++ = uvRect.left;
        *pVert++ = uvRect.bottom;

        top += mCharHeight * 2.0f;
        left += horiz_height * mCharHeight * 2.0f;

        // Top right
        *pVert++ = left;
        *pVert++ = top;
        *pVert++ = -1.0;
        *pVert++ = uvRect.right;
        *pVert++ = uvRect.top;
        //-------------------------------------------------------------------------------------

        //-------------------------------------------------------------------------------------
        // Second tri
        //
        // Top right (again)
        *pVert++ = left;
        *pVert++ = top;
        *pVert++ = -1.0;
        *pVert++ = uvRect.right;
        *pVert++ = uvRect.top;

        top -= mCharHeight * 2.0f;
        left -= horiz_height  * mCharHeight * 2.0f;

        // Bottom left (again)
        *pVert++ = left;
        *pVert++ = top;
        *pVert++ = -1.0;
        *pVert++ = uvRect.left;
        *pVert++ = uvRect.bottom;

        left += horiz_height  * mCharHeight * 2.0f;

        // Bottom right
        *pVert++ = left;
        *pVert++ = top;
        *pVert++ = -1.0;
        *pVert++ = uvRect.right;
        *pVert++ = uvRect.bottom;
        //-------------------------------------------------------------------------------------

        // Go back up with top
        top += mCharHeight * 2.0f;

        float currentWidth = (left + 1)/2 - _getDerivedLeft();
        if (currentWidth > largestWidth)
        {
            largestWidth = currentWidth;

        }
    }
    // Unlock vertex buffer
    vbuf->unlock();

    if (mMetricsMode == GMM_PIXELS)
    {
        // Derive parametric version of dimensions
        Real vpWidth;
        vpWidth = (Real) (OverlayManager::getSingleton().getViewportWidth());

        largestWidth *= vpWidth;
    };

    if (getWidth() < largestWidth)
        setWidth(largestWidth);
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:101,代码来源:OgreTextAreaOverlayElement.cpp


示例16: setWidth

void Camera::setSize(int width_arg, int height_arg)
{
    setWidth(width_arg);
    setHeight(height_arg);
}
开发者ID:pibomb,项目名称:crowbot,代码行数:5,代码来源:Camera.cpp


示例17: setWidth

void
RectangleBounds::setDimensions( float w, float h )
{
    setWidth( w );
    setHeight( h );
}
开发者ID:Cynapium,项目名称:intro-to-game-dev,代码行数:6,代码来源:rectangle_bounds.cpp


示例18: Rect

// on "init" you need to initialize your instance
bool Scene102::init()
{
	//////////////////////////////
	// 1. super init first
	if (!Layer::init())
	{
		return false;
	}

	Size visibleSize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();
	Size size;

	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Scene101/scene101.plist");
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Scene101/scene101bg.plist");

	//以 Sprite 作為背景
	Sprite *bkimage = Sprite::createWithSpriteFrameName("s101bgimg.png");  // 使用 create 函式,給予檔名即可
	bkimage->setPosition(Vec2(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y)); // 位置通常放置在螢幕正中間
	this->addChild(bkimage, 0);

	// 自行增加 sprite 將 bean01.png 到螢幕正中間


	// create and initialize a label, add a label shows "Scene 101"
	auto label = Label::createWithTTF("Scene 101", "fonts/Marker Felt.ttf", 32);
	label->setAlignment(cocos2d::TextHAlignment::CENTER); // 預設靠左對齊
	label->setWidth(100);	// 設定每行文字的顯示寬度
	size = label->getContentSize();
	label->setPosition(Vec2(origin.x + visibleSize.width - size.width / 2 - 10, origin.y + visibleSize.height - size.height / 2 - 10));
	this->addChild(label, 1);

	this->_sceneno = 102;
	strcpy(this->_cSceneNo, "Scene 102");

	//一般(非中文字)文字的顯示方式
	_label1 = Label::createWithBMFont("fonts/couriernew32.fnt", "Scene 101");
	size = _label1->getContentSize();
	_label1->setColor(Color3B::WHITE);
	_label1->setPosition(Vec2(origin.x + visibleSize.width / 2, origin.y + visibleSize.height - size.height));
	this->addChild(_label1, 1);

	// 中文字的顯示方式
	auto strings = FileUtils::getInstance()->getValueMapFromFile("scene101/strings.xml");
	std::string str1 = strings["chinese1"].asString();
	std::string str2 = strings["chinese2"].asString();
	auto label2 = Label::createWithBMFont("fonts/hansans48.fnt", str1);
	auto label3 = Label::createWithBMFont("fonts/hansans48.fnt", str2);
	size = label2->getContentSize();
	label2->setColor(Color3B(255, 238, 217));
	label2->setPosition(Vec2(origin.x + visibleSize.width / 2, origin.y + visibleSize.height - 80 - size.height));
	this->addChild(label2, 1);

	label3->setColor(Color3B(250, 251, 170));
	size = label3->getContentSize();
	label3->setPosition(Vec2(origin.x + visibleSize.width / 2, origin.y + visibleSize.height - 140 - size.height));
	this->addChild(label3, 1);

	// add Return Button
	this->returnbtn = Sprite::createWithSpriteFrameName("returnbtn.png");
	size = returnbtn->getContentSize();
	this->returnbtn->setPosition(Vec2(origin.x + size.width / 2 + 5, origin.y + visibleSize.height - size.height / 2 - 5));
	Point pos = returnbtn->getPosition();
	this->rectReturn = Rect(pos.x - size.width / 2, pos.y - size.height / 2, size.width, size.height);
	this->addChild(returnbtn, 1);

	// add Replay Button
	this->replaybtn = Sprite::createWithSpriteFrameName("replaybtn.png");
	size = replaybtn->getContentSize();
	this->replaybtn->setPosition(Vec2(origin.x + size.width / 2 + 90, origin.y + visibleSize.height - size.height / 2 - 5));
	pos = replaybtn->getPosition();
	this->rectReplay = Rect(pos.x - size.width / 2, pos.y - size.height / 2, size.width, size.height);
	this->addChild(replaybtn, 1);

	// add Cuber Button
	this->cuberbtn = Sprite::createWithSpriteFrameName("cuberbtn1.png");
	size = cuberbtn->getContentSize();
	this->cuberbtn->setPosition(Vec2(origin.x + visibleSize.width - size.width / 2, origin.y + visibleSize.height - size.height / 2 - 60));
	pos = cuberbtn->getPosition();
	this->rectCuber = Rect(pos.x - size.width / 2, pos.y - size.height / 2, size.width, size.height);
	this->addChild(cuberbtn, 1);

	_listener1 = EventListenerTouchOneByOne::create();	//創建一個一對一的事件聆聽器
	_listener1->onTouchBegan = CC_CALLBACK_2(Scene102::onTouchBegan, this);		//加入觸碰開始事件
	_listener1->onTouchMoved = CC_CALLBACK_2(Scene102::onTouchMoved, this);		//加入觸碰移動事件
	_listener1->onTouchEnded = CC_CALLBACK_2(Scene102::onTouchEnded, this);		//加入觸碰離開事件

	this->_eventDispatcher->addEventListenerWithSceneGraphPriority(_listener1, this);	//加入剛創建的事件聆聽器
	this->schedule(CC_SCHEDULE_SELECTOR(Scene102::doStep));

	return true;
}
开发者ID:TonyCheng2016,项目名称:GitHubCocos2DX,代码行数:93,代码来源:Scene102.cpp


示例19: setModal

void Inventory::init()
{
    if (_initialized) return;
    State::init();

    setModal(true);
    setFullscreen(false);

    auto game = Game::getInstance();
    auto panelHeight = Game::getInstance()->locationState()->playerPanelState()->height();

    setX((game->renderer()->width()  - 499)/2); // 499x377 = art/intrface/invbox.frm
    setY((game->renderer()->height() - 377 - panelHeight)/2);

    addUI("background", new Image("art/intrface/invbox.frm"));
    getActiveUI("background")->addEventHandler("mouserightclick", [this](Event* event){ this->backgroundRightClick(dynamic_cast<MouseEvent*>(event)); });

    addUI("button_up",   new ImageButton(ImageButton::TYPE_INVENTORY_UP_ARROW,   128, 40));
    addUI("button_down", new ImageButton(ImageButton::TYPE_INVENTORY_DOWN_ARROW, 128, 65));

    addUI("button_done", new ImageButton(ImageButton::TYPE_SMALL_RED_CIRCLE, 438, 328));
    getActiveUI("button_done")->addEventHandler("mouseleftclick", [this](Event* event){ this->onDoneButtonClick(dynamic_cast<MouseEvent*>(event)); });

    // screen
    auto screenX = 300;
    auto screenY = 47;

    auto player = Game::getInstance()->player();

    addUI("player_name", new TextArea(player->name(), screenX, screenY));

    auto line1 = new Image(142, 1);
    line1->setX(screenX);
    line1->setY(screenY+16);
    line1->texture()->fill(0x3ff800ff); // default green color

    std::string statsLabels;
    for (unsigned int i = 0; i != 7; ++i) statsLabels += _t(MSG_INVENTORY, i) + "\n";
    addUI("label_stats", new TextArea(statsLabels, screenX, screenY + 10*2));

    std::string statsValues;
    for (unsigned int i = 0; i != 7; ++i) statsValues += std::to_string(player->stat(i)) + "\n";
    addUI("label_stats_values", new TextArea(statsValues, screenX + 22, screenY + 20));

    std::stringstream ss;
    for (unsigned int i=7; i<14; i++)
    {
        ss << _t(MSG_INVENTORY, i) << "\n";
    }
    auto textLabel = new TextArea(ss.str(), screenX+40, screenY+20);

    // label: hit points
    ss.str("");
    ss << player->hitPoints();
    ss << "/";
    ss << player->hitPointsMax();
    auto hitPointsLabel = new TextArea(ss.str(), screenX+94, screenY+20);
    hitPointsLabel->setWidth(46)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_RIGHT);
    // label: armor class
    ss.str("");
    ss << player->armorClass();
    auto armorClassLabel = new TextArea(ss.str(), screenX+94, screenY+30);
    armorClassLabel->setWidth(46)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_RIGHT);

    // armorSlot, leftHand, rightHand
    Game::GameArmorItemObject* armorSlot = player->armorSlot();
    Game::GameItemObject* leftHand = player->leftHandSlot();
    Game::GameItemObject* rightHand = player->rightHandSlot();


    // label: damage treshold levels
    ss.str("");
    if (armorSlot)
    {
        ss << player->damageThreshold(Game::GameCritterObject::DAMAGE_NORMAL) + armorSlot->damageThreshold(Game::GameArmorItemObject::DAMAGE_NORMAL) <<"/\n";
        ss << player->damageThreshold(Game::GameCritterObject::DAMAGE_LASER) + armorSlot->damageThreshold(Game::GameArmorItemObject::DAMAGE_LASER) <<"/\n";
        ss << player->damageThreshold(Game::GameCritterObject::DAMAGE_FIRE) + armorSlot->damageThreshold(Game::GameArmorItemObject::DAMAGE_FIRE) <<"/\n";
        ss << player->damageThreshold(Game::GameCritterObject::DAMAGE_PLASMA) + armorSlot->damageThreshold(Game::GameArmorItemObject::DAMAGE_PLASMA) <<"/\n";
        ss << player->damageThreshold(Game::GameCritterObject::DAMAGE_EXPLOSION) + armorSlot->damageThreshold(Game::GameArmorItemObject::DAMAGE_NORMAL) <<"/";
    }
    else
    {
        ss << player->damageThreshold(Game::GameCritterObject::DAMAGE_NORMAL) <<"/\n";
        ss << player->damageThreshold(Game::GameCritterObject::DAMAGE_LASER) <<"/\n";
        ss << player->damageThreshold(Game::GameCritterObject::DAMAGE_FIRE) <<"/\n";
        ss << player->damageThreshold(Game::GameCritterObject::DAMAGE_PLASMA) <<"/\n";
        ss << player->damageThreshold(Game::GameCritterObject::DAMAGE_EXPLOSION) <<"/";
    }
    auto damageThresholdLabel = new TextArea(ss.str(), screenX+94, screenY+40);
    damageThresholdLabel->setWidth(26)->setHorizontalAlign(TextArea::HORIZONTAL_ALIGN_RIGHT);

    // label: damage resistance levels
    ss.str("");
    if (armorSlot)
    {
        ss << player->damageResist(Game::GameCritterObject::DAMAGE_NORMAL) + armorSlot->damageResist(Game::GameArmorItemObject::DAMAGE_NORMAL) <<"%\n";
        ss << player->damageResist(Game::GameCritterObject::DAMAGE_LASER) + armorSlot->damageResist(Game::GameArmorItemObject::DAMAGE_LASER) <<"%\n";
        ss << player->damageResist(Game::GameCritterObject::DAMAGE_FIRE) + armorSlot->damageResist(Game::GameArmorItemObject::DAMAGE_FIRE) <<"%\n";
        ss << player->damageResist(Game::GameCritterObject::DAMAGE_PLASMA) + armorSlot->damageResist(Game::GameArmorItemObject::DAMAGE_PLASMA) <<"%\n";
        ss << player->damageResist(Game::GameCritterObject::DAMAGE_EXPLOSION) + armorSlot->damageResist(Game::GameArmorItemObject::DAMAGE_NORMAL) <<"%";
//.........这里部分代码省略.........
开发者ID:vvbalashoff,项目名称:falltergeist,代码行数:101,代码来源:Inventory.cpp


示例20: init

void PropertyField::init(cocos2d::Layer *propertyLayer)
{
    _propertyLayer = propertyLayer;

    _headImage = Sprite::create("images/property/idle_head.png");
    _headImage->setPosition(DDConfig::relativePos(0.13, 0.13));
    _headImage->setScale(DDConfig::relativeScaler(1.f));
    _headImage->setZOrder(Z_HEAD_IMAGE);
    _propertyLayer->addChild(_headImage);

    _titleLabel = Label::createWithTTF("Idle title", TRLocale::s().font(), 30*DDConfig::fontSizeRadio());
    _titleLabel->setPosition(DDConfig::relativePos(0.5, 0.12));
    _titleLabel->setWidth(DDConfig::relativeScaler(1.f)*300);
    _titleLabel->setAlignment(TextHAlignment::LEFT);
    _titleLabel->setZOrder(Z_TEXT);
    _propertyLayer->addChild(_titleLabel);

    _describeLabel = Label::createWithTTF("Describe text string...", TRLocale::s().font(), 25*DDConfig::fontSizeRadio());
    _describeLabel->setPosition(DDConfig::relativePos(0.5, 0.095));
    _describeLabel->setWidth(DDConfig::relativeScaler(1.f)*300);
    _describeLabel->setAlignment(TextHAlignment::LEFT);
    _describeLabel->setZOrder(Z_TEXT);
    _propertyLayer->addChild(_describeLabel);

    float x_now = 0.31;
    float x_step = 0.12;
    float y_image = 0.045;
    float y_num_diff = -0.012;
    float y_cost_diff = -0.028;
    float x_cost_diff = 0.005;
    float x_text_width = 60*DDConfig::relativeScaler(1.0);

    auto genPropertyNode = [this, y_num_diff, y_cost_diff,x_cost_diff, x_text_width](float x, float y){
        PropertyNode ret;
        auto image = Sprite::create("images/property/idle_property.png");
        image->setPosition(DDConfig::relativePos(x, y));
        image->setScale(DDConfig::relativeScaler(0.7f));
        image->setZOrder(Z_PROPERTY_IMAGE);
        _propertyLayer->addChild(image);
        ret.image = image;

        auto num = Label::createWithTTF("2/10", TRLocale::s().font(), 18*DDConfig::fontSizeRadio());
        num->setPosition(DDConfig::relativePos(x, y + y_num_diff));
        num->setZOrder(Z_PROPERTY_NUM);
        num->setWidth(x_text_width);
        num->setAlignment(TextHAlignment::RIGHT);
        _propertyLayer->addChild(num);
        ret.numLabel = num;


        auto cost = Label::createWithTTF("200", TRLocale::s().font(), 18*DDConfig::fontSizeRadio());
        cost->setPosition(DDConfig::relativePos(x+x_cost_diff, y + y_cost_diff));
        cost->setZOrder(Z_PROPERTY_COST);
        cost->setWidth(x_text_width);
        cost->setAlignment(TextHAlignment::CENTER);
        _propertyLayer->addChild(cost);
        ret.costLabel = cost;
        return  ret;
    };

    // 下方基本图标序列
    for (int i = 0; i < NUM_PROPERTY_MAX; i++) {
        _propertyNodes[i] = genPropertyNode(x_now, y_image);
        x_now += x_step;
    }

    // 五行属性图标
    _elementTypeIcon = genPropertyNode(x_now, 0.105);

    // 移除售卖
    _removeIcon = genPropertyNode(x_now, y_image);

/*
    _buildingImage = Sprite::create("images/template_buildings.png");
    _buildingImage->setPosition(DDConfig::buildingAreaCenter());
    auto rect = DDConfig::buildingAreaRect();
    _buildingImage->setScale(rect.size.width/_buildingImage->getContentSize().width);
    _buildingImage->setZOrder(Z_BUILDING_IMAGE);
    _buildingLayer->addChild(_buildingImage);

    _selectionIcon = Sprite::create("images/template_buildings_select_icon.png");
    _selectionIcon->setScale(rect.size.height/_selectionIcon->getContentSize().height);
    _selectionIcon->setVisible(false);
    _selectionIcon->setZOrder(Z_SELECT_ICON);
    _buildingLayer->addChild(_selectionIcon);



    auto listener = EventListenerTouchOneByOne::create();

    listener->onTouchBegan = [this](Touch* touch, Event* event){
        auto point = touch->getLocation();
        auto rect = DDConfig::buildingAreaRect();
        touch_moved = false;
        return rect.containsPoint(point);
    };

    listener->onTouchMoved = [this](Touch* touch, Event* event){
        touch_moved = true;
    };
//.........这里部分代码省略.........
开发者ID:dgkae,项目名称:NormalMapPreviewer,代码行数:101,代码来源:PropertyField.cpp



注:本文中的setWidth函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setWindow函数代码示例发布时间:2022-05-30
下一篇:
C++ setWidgetResizable函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap