コード例 #1
0
ファイル: QLabel.cpp プロジェクト: sbc100/OpenQuick
//------------------------------------------------------------------------------
void QLabel::init()
{
	// This needs to be called after the LUA variables have been submitted to
    // the object.  TODO we want to support TTF rendering, but not through the
    // CQabelTTF class as the implimentation they chose is teh suck!
	QAssert(font != NULL, "label font is null");

    // Create and retain the node
    CCLabelNode *node = new CCLabelNode(this);
    m_CCNode = node;
    m_CCNode->retain();

    // Set the width to the box width if one is specified
    float width = GetCalculatedWidth();
    float text_width = width - textBorderLeft - textBorderRight;
    float height = GetCalculatedHeight();

    // Get the alignment information
    cocos2d::CCTextAlignment halign_val;
    cocos2d::CCVerticalTextAlignment valign_val;
    GetCurrentAlignment( &halign_val, &valign_val);

    // Create the label and add it to the node (node holds the reference)
    m_CCFontNode = CCLabelBMFont::create( text.c_str(),
                                          font->get_fileName().c_str(),
                                          text_width,
                                          halign_val);
    m_CCNode->addChild(m_CCFontNode);

    // Calculate the size of the text if we aren't rendering into a box
    CalculateSize();

    // Now set the anchor and position of the CQabel
    SetAlignmentAnchors( halign_val, valign_val);

    m_CCNode->setPosition( x, y);
	m_CCNode->setAnchorPoint(ccp(xAnchor, yAnchor));

    m_CachedWidth = width;
    m_CachedHeight = height;
    m_CachedHAlignment = hAlignment;
	m_CachedVAlignment = vAlignment;

    m_CachedTextBorderTop = textBorderTop;
    m_CachedTextBorderBottom = textBorderBottom;
    m_CachedTextBorderLeft = textBorderLeft;
    m_CachedTextBorderRight = textBorderRight;

    m_CachedTextXScale = textXScale;
    m_CachedTextYScale = textYScale;
}
コード例 #2
0
//------------------------------------------------------------------------------
void QNodeProps::_addShapePoint(float x, float y)
{
    QAssert(m_NumShapePoints < MAX_SHAPE_POINTS, "Too many points submitted to shape");

    // Shape points are always defined relative to an anchor point of (0, 0)
    // However, we permit the node to have a different anchor point, provided it remains the same throughout all point adding,
    // and thereafter.
    if ((!m_Node->w) || (!m_Node->h))
    {
        // sync() the node, to ensure fields up to date, e.g. w/h for sprites
        m_Node->sync();
    }

    float xOfs = m_Node->w * m_Node->xScale * m_Node->xAnchor;
    float yOfs = m_Node->h * m_Node->yScale * m_Node->yAnchor;
    m_ShapePoints[m_NumShapePoints].x = g_Sim->scaleD2P(x - xOfs);
    m_ShapePoints[m_NumShapePoints].y = g_Sim->scaleD2P(y - yOfs);
    m_NumShapePoints++;
}
コード例 #3
0
//------------------------------------------------------------------------------
void QNodeProps::set_isSensor(bool v)
{
	QAssert(false, ("Trying to set read-only property isSensor"));
}