本文整理汇总了C++中CC_CONTENT_SCALE_FACTOR函数的典型用法代码示例。如果您正苦于以下问题:C++ CC_CONTENT_SCALE_FACTOR函数的具体用法?C++ CC_CONTENT_SCALE_FACTOR怎么用?C++ CC_CONTENT_SCALE_FACTOR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CC_CONTENT_SCALE_FACTOR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load
CCSPXFileData* CCSPXLoader::load(const char* spxPath) {
unsigned long len;
string mappedPath = CCUtils::mapLocalPath(spxPath);
char* data = (char*)CCFileUtils::sharedFileUtils()->getFileData(mappedPath.c_str(), "rb", &len);
CCSPXFileData* spx = load(data, (size_t)len, 1 / CC_CONTENT_SCALE_FACTOR());
spx->m_path = spxPath;
free(data);
return spx;
}
示例2: ccDrawPoint
void ccDrawPoint(const CCPoint& point)
{
ccVertex2F p = {point.x * CC_CONTENT_SCALE_FACTOR(), point.y * CC_CONTENT_SCALE_FACTOR() };
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
// Needed states: GL_VERTEX_ARRAY,
// Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY, GL_COLOR_ARRAY
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, &p);
glDrawArrays(GL_POINTS, 0, 1);
// restore default state
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
}
示例3: ccpMult
void CCNode::setPositionInPixels(CCPoint newPosition)
{
m_tPositionInPixels = newPosition;
if ( CC_CONTENT_SCALE_FACTOR() == 1)
{
m_tPosition = m_tPositionInPixels;
}
else
{
m_tPosition = ccpMult(newPosition, 1/CC_CONTENT_SCALE_FACTOR());
}
m_bIsTransformDirty = m_bIsInverseDirty = true;
#if CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
m_bIsTransformGLDirty = true;
#endif // CC_NODE_TRANSFORM_USING_AFFINE_MATRIX
}
示例4: CC_CONTENT_SCALE_FACTOR
void CCCamera::setCenterXYZ(float fCenterX, float fCenterY, float fCenterZ)
{
float scale = CC_CONTENT_SCALE_FACTOR();
m_fCenterX = fCenterX * scale;
m_fCenterY = fCenterY * scale;
m_fCenterZ = fCenterZ * scale;
m_bDirty = true;
}
示例5: addChild
//------------------------------------------------------------------
//
// Rookie Guide Layer
//
//------------------------------------------------------------------
void CommonRookieGuide::onEnter()
{
CommonDemo::onEnter();
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCSprite* g1 = CCSprite::create("Images/grossini.png");
g1->setPosition(ccp(origin.x + visibleSize.width / 4,
origin.y + visibleSize.height / 2));
addChild(g1);
CCSprite* g2 = CCSprite::create("Images/grossini.png");
g2->setPosition(ccp(origin.x + visibleSize.width * 3 / 4,
origin.y + visibleSize.height / 2));
addChild(g2);
// create rookie guide
CCSimpleRookieGuide* rg = CCSimpleRookieGuide::create();
// set bg
rg->setBgColor(ccc4(0xff, 0, 0, 0x4f));
// add region
rg->addRegion(g2,
CCCallFunc::create(this, callfunc_selector(CommonRookieGuide::onGuideClicked)));
// set arrow
rg->setArrow(CCSprite::create("Images/f1.png"));
rg->pointToRegionCenter(0, 100 / CC_CONTENT_SCALE_FACTOR(), 200);
// set hint
CCRichLabelTTF* hint = CCRichLabelTTF::create("[color=0xff0000ff]This is rookie guide, you MUST click it![/color]",
"Helvetica",
24 / CC_CONTENT_SCALE_FACTOR(),
CCSizeMake(150 / CC_CONTENT_SCALE_FACTOR(), 0),
kCCTextAlignmentLeft);
rg->setHint(hint);
rg->shiftHint(-80 / CC_CONTENT_SCALE_FACTOR(), -20 / CC_CONTENT_SCALE_FACTOR());
// add guide layer, must add it after set
addChild(rg);
}
示例6: CCAssert
bool CCLabelAtlas::initWithString(const char *theString, const char *fntFile)
{
std::string pathStr = CCFileUtils::sharedFileUtils()->fullPathForFilename(fntFile);
std::string relPathStr = pathStr.substr(0, pathStr.find_last_of("/"))+"/";
CCDictionary *dict = CCDictionary::createWithContentsOfFile(pathStr.c_str());
CCAssert(((CCString*)dict->objectForKey("version"))->intValue() == 1, "Unsupported version. Upgrade cocos2d version");
std::string texturePathStr = relPathStr + ((CCString*)dict->objectForKey("textureFilename"))->getCString();
CCString *textureFilename = CCString::create(texturePathStr);
unsigned int width = ((CCString*)dict->objectForKey("itemWidth"))->intValue() / CC_CONTENT_SCALE_FACTOR();
unsigned int height = ((CCString*)dict->objectForKey("itemHeight"))->intValue() / CC_CONTENT_SCALE_FACTOR();
unsigned int startChar = ((CCString*)dict->objectForKey("firstChar"))->intValue();
this->initWithString(theString, textureFilename->getCString(), width, height, startChar);
return true;
}
示例7: CC_CONTENT_SCALE_FACTOR
void CCEGLView::setScissorInPoints(float x, float y, float w, float h) {
//TODO
if (bIsInit) {
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
glScissor((GLint)(x * factor) + m_rcViewPort.origin.x,
(GLint)(y * factor) + m_rcViewPort.origin.y,
(GLint)(w * factor),
(GLint)(h * factor));
}
}
示例8: ccpMult
void CCBlade::push(CCPoint v)
{
if (isReset)
{
return;
}
if (CC_CONTENT_SCALE_FACTOR() != 1.0f) {
v = ccpMult(v, CC_CONTENT_SCALE_FACTOR());
}
#if USE_LAGRANGE
if (path.size() == 0)
{
path.insert(path.begin(),v);
return;
}
CCPoint first = path[0];
if (ccpDistance(v, first) < DISTANCE_TO_INTERPOLATE) {
path.insert(path.begin(),v);
if (path.size() > pointLimit) {
path.pop_back();
}
}else{
int num = ccpDistance(v, first) / DISTANCE_TO_INTERPOLATE;
CCPoint iv = ccpMult(ccpSub(v, first), (float)1./(num + 1));
for (int i = 1; i <= num + 1; i++) {
path.insert(path.begin(),ccpAdd(first, ccpMult(iv, i)));
}
while (path.size() > pointLimit) {
path.pop_back();
}
}
#else // !USE_LAGRANGE
path.push_front(v);
if (path.size() > pointLimit) {
path.pop_back();
}
#endif // !USE_LAGRANGE
this->populateVertices();
}
示例9: glViewport
void CCGridBase::set2DProjection()
{
CCDirector *director = CCDirector::sharedDirector();
CCSize size = director->getWinSizeInPixels();
glViewport(0, 0, (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()) );
kmGLMatrixMode(KM_GL_PROJECTION);
kmGLLoadIdentity();
kmMat4 orthoMatrix;
kmMat4OrthographicProjection(&orthoMatrix, 0, size.width * CC_CONTENT_SCALE_FACTOR(), 0, size.height * CC_CONTENT_SCALE_FACTOR(), -1, 1);
kmGLMultMatrix( &orthoMatrix );
kmGLMatrixMode(KM_GL_MODELVIEW);
kmGLLoadIdentity();
ccSetProjectionMatrixDirty();
}
示例10: CC_CONTENT_SCALE_FACTOR
void Label::updateBMFontScale()
{
auto font = _fontAtlas->getFont();
if (_currentLabelType == LabelType::BMFONT) {
FontFNT *bmFont = (FontFNT*)font;
float originalFontSize = bmFont->getOriginalFontSize();
_bmfontScale = _bmFontSize * CC_CONTENT_SCALE_FACTOR() / originalFontSize;
}else{
_bmfontScale = 1.0f;
}
}
示例11: CCAssert
bool CCLabelTTF::initWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize)
{
CCAssert(label != NULL, "");
if (CCSprite::init())
{
// shader program
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(SHADER_PROGRAM));
m_tDimensions = CCSizeMake( dimensions.width * CC_CONTENT_SCALE_FACTOR(), dimensions.height * CC_CONTENT_SCALE_FACTOR() );
m_eAlignment = alignment;
CC_SAFE_DELETE(m_pFontName);
m_pFontName = new std::string(fontName);
m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR();
this->setString(label);
return true;
}
return false;
}
示例12: CC_CONTENT_SCALE_FACTOR
void CCEGLView::setViewPortInPoints(float x, float y, float w, float h)
{
if (m_pEGL)
{
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
glViewport((GLint)(x * factor) + m_rcViewPort.X(),
(GLint)(y * factor) + m_rcViewPort.Y(),
(GLint)(w * factor),
(GLint)(h * factor));
}
}
示例13: CC_CONTENT_SCALE_FACTOR
/// override contentSize
void CCLayerColor::setContentSize(const CCSize& size)
{
float scale = CC_CONTENT_SCALE_FACTOR();
m_pSquareVertices[1].x = size.width * scale;
m_pSquareVertices[2].y = size.height * scale;
m_pSquareVertices[3].x = size.width * scale;
m_pSquareVertices[3].y = size.height * scale;
CCLayer::setContentSize(size);
}
示例14: glBindFramebuffer
void CCRenderTexture::end()
{
glBindFramebuffer(GL_FRAMEBUFFER, m_nOldFBO);
kmGLPopMatrix();
CCDirector *director = CCDirector::sharedDirector();
CCSize size = director->getWinSizeInPixels();
// restore viewport
glViewport(0, 0, GLsizei(size.width * CC_CONTENT_SCALE_FACTOR()), GLsizei(size.height * CC_CONTENT_SCALE_FACTOR()));
// special viewport for 3d projection + retina display
if ( director->getProjection() == kCCDirectorProjection3D && CC_CONTENT_SCALE_FACTOR() != 1 )
{
glViewport((GLsizei)(-size.width/2), (GLsizei)(-size.height/2), (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()));
}
director->setProjection(director->getProjection());
}
示例15: CCASSERT
bool LabelAtlas::initWithString(const std::string& theString, const std::string& fntFile)
{
std::string pathStr = FileUtils::getInstance()->fullPathForFilename(fntFile);
std::string relPathStr = pathStr.substr(0, pathStr.find_last_of("/"))+"/";
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(pathStr.c_str());
CCASSERT(dict["version"].asInt() == 1, "Unsupported version. Upgrade cocos2d version");
std::string textureFilename = relPathStr + dict["textureFilename"].asString();
unsigned int width = dict["itemWidth"].asInt() / CC_CONTENT_SCALE_FACTOR();
unsigned int height = dict["itemHeight"].asInt() / CC_CONTENT_SCALE_FACTOR();
unsigned int startChar = dict["firstChar"].asInt();
this->initWithString(theString, textureFilename.c_str(), width, height, startChar);
return true;
}