您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CC_POINT_PIXELS_TO_POINTS函数代码示例

51自学网 2021-06-01 19:57:40
  C++
这篇教程C++ CC_POINT_PIXELS_TO_POINTS函数代码示例写得很实用,希望能帮到您。

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

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

示例1: log

bool HelloWorld::init(){    if ( !LayerColor::initWithColor(Color4B(255, 255, 255, 255) ))    {        return false;    }	auto map = TMXTiledMap::create("TileMaps/iso-test-zorder.tmx");	this->addChild(map, 0, 1);	Size s = map->getContentSize();	log("ContentSize : %f, %f", s.width, s.height);	map->setPosition(Vec2(-s.width/2 , 0));	m_tamara = Sprite::create("Images/grossinis_sister1.png");	map->addChild(m_tamara, map->getChildren().size());	int mapWidth = map->getMapSize().width * map->getTileSize().width;	m_tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Vec2(mapWidth / 2, 0)));	m_tamara->setAnchorPoint(Vec2(0.5f, 0));	auto move = MoveBy::create(10, Vec2(300, 250));	auto back = move->reverse();	auto seq = Sequence::create(move, back, nullptr);	m_tamara->runAction(RepeatForever::create(seq));	schedule(schedule_selector(HelloWorld::repositionSprite));    return true;}
开发者ID:kimsibaek,项目名称:cocos2d-x-work,代码行数:29,


示例2: log

void TileMap::setPlayerPosition(Point position, Player player) {	std::string pathAhead = this->metaLayerChecker(position);	if (pathAhead == "Edge") {		log("Stopped by the Edge of the map");	}	else if ((pathAhead == "Solid") && (player.getPower().getSolid() == false)) {		log("Stopped by Solid");	}	else if ((pathAhead == "Water") && (player.getPower().getWater()==false)) {		log("Stopped by Water");	}	else if ((pathAhead == "Ice") && (player.getPower().getIce() == false)) {		log("Stopped by Ice");	}	else if ((pathAhead == "Fire") && (player.getPower().getFire() == false)) {		log("Stopped by Fire");	}	else if (pathAhead == "segundoNivel"){		log("Nivel1 Completado");		Size visibleSize = Director::getInstance()->getVisibleSize();		auto label1 = LabelTTF::create("Nivel1 Completado", "Book Antigua", 40);		label1->setPosition(Point(visibleSize.width / 2, visibleSize.height / 2));		this->addChild(label1, 1);		auto newScene = SegundoNivel::createScene();		Director::getInstance()->replaceScene(CCTransitionFade::create(7.5f, newScene));	}	else if (pathAhead == "tercerNivel"){		log("Nivel2 Completado");		Size visibleSize = Director::getInstance()->getVisibleSize();		auto label1 = LabelTTF::create("Nivel2 Completado", "Book Antigua", 40);		label1->setPosition(Point(visibleSize.width / 2, visibleSize.height / 2));		this->addChild(label1, 1);		auto newScene = TercerNivel::createScene();		Director::getInstance()->replaceScene(CCTransitionFade::create(7.5f, newScene));	}else if (pathAhead == "finishGame"){		log("Nivel3 Completado");		Size visibleSize = Director::getInstance()->getVisibleSize();		auto label1 = LabelTTF::create("Nivel3 Completado", "Book Antigua", 40);		label1->setPosition(Point(visibleSize.width / 2, visibleSize.height / 2));		this->addChild(label1, 1);		auto newScene = MenuInicio::createScene();		Director::getInstance()->replaceScene(CCTransitionFade::create(7.5f, newScene));	}	else{		player.setPosition(position);		Point View = setPointOfViewCenter(position);		tileMap->setPosition(CC_POINT_PIXELS_TO_POINTS(View));		this->loadPowers(position, player, pathAhead);	}}
开发者ID:Magnus1Proyect,项目名称:Magnus,代码行数:54,


示例3: setScaleX

bool CCTMXLayer::initWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo){        // XXX: is 35% a good estimate ?    CCSize size = layerInfo->m_tLayerSize;    float totalNumberOfTiles = size.width * size.height;    float capacity = totalNumberOfTiles * 0.35f + 1; // 35 percent is occupied ?    CCTexture2D *texture = NULL;    if( tilesetInfo )    {        texture = CCTextureCache::sharedTextureCache()->addImage(tilesetInfo->m_sSourceImage.c_str());    }    if (CCSpriteBatchNode::initWithTexture(texture, (unsigned int)capacity))    {		if(tilesetInfo->m_IsNeedFlipX)		{			layerInfo->m_tOffset.x = layerInfo->m_tLayerSize.width;			setScaleX(-1);		}        // layerInfo        m_sLayerName = layerInfo->m_sName;        m_tLayerSize = size;        m_pTiles = layerInfo->m_pTiles;        m_uMinGID = layerInfo->m_uMinGID;        m_uMaxGID = layerInfo->m_uMaxGID;        m_cOpacity = layerInfo->m_cOpacity;        setProperties(CCDictionary::createWithDictionary(layerInfo->getProperties()));        m_fContentScaleFactor = CCDirector::sharedDirector()->getContentScaleFactor();         // tilesetInfo        m_pTileSet = tilesetInfo;        CC_SAFE_RETAIN(m_pTileSet);        // mapInfo        m_tMapTileSize = mapInfo->getTileSize();        m_uLayerOrientation = mapInfo->getOrientation();        // offset (after layer orientation is set);        CCPoint offset = this->calculateLayerOffset(layerInfo->m_tOffset);        this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset));        m_pAtlasIndexArray = ccCArrayNew((unsigned int)totalNumberOfTiles);        this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(CCSizeMake(m_tLayerSize.width * m_tMapTileSize.width, m_tLayerSize.height * m_tMapTileSize.height)));        m_bUseAutomaticVertexZ = false;        m_nVertexZvalue = 0;                return true;    }    return false;}
开发者ID:hick1213,项目名称:cocos2dx-2.2-dds-texture-support,代码行数:53,


示例4: setProperties

bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo){        // FIXME:: is 35% a good estimate ?    Size size = layerInfo->_layerSize;    float totalNumberOfTiles = size.width * size.height;    float capacity = totalNumberOfTiles * 0.35f + 1; // 35 percent is occupied ?    Texture2D *texture = nullptr;    if( tilesetInfo )    {        texture = Director::getInstance()->getTextureCache()->addImage(tilesetInfo->_sourceImage);    }    if (nullptr == texture)        return false;    if (SpriteBatchNode::initWithTexture(texture, static_cast<ssize_t>(capacity)))    {        // layerInfo        _layerName = layerInfo->_name;        _layerSize = size;        _tiles = layerInfo->_tiles;        _opacity = layerInfo->_opacity;        setProperties(layerInfo->getProperties());        _contentScaleFactor = Director::getInstance()->getContentScaleFactor();         // tilesetInfo        _tileSet = tilesetInfo;        CC_SAFE_RETAIN(_tileSet);        // mapInfo        _mapTileSize = mapInfo->getTileSize();        _layerOrientation = mapInfo->getOrientation();        _staggerAxis = mapInfo->getStaggerAxis();        _staggerIndex = mapInfo->getStaggerIndex();        _hexSideLength = mapInfo->getHexSideLength();        // offset (after layer orientation is set);        Vec2 offset = this->calculateLayerOffset(layerInfo->_offset);        this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset));        _atlasIndexArray = ccCArrayNew(totalNumberOfTiles);        this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(Size(_layerSize.width * _mapTileSize.width, _layerSize.height * _mapTileSize.height)));        _useAutomaticVertexZ = false;        _vertexZvalue = 0;                return true;    }    return false;}
开发者ID:krzysztof-jusiak,项目名称:pi,代码行数:52,


示例5: CC_RECT_PIXELS_TO_POINTS

bool SpriteFrame::initWithTextureFilename(const char* filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize){    _texture = NULL;    _textureFilename = filename;    _rectInPixels = rect;    _rect = CC_RECT_PIXELS_TO_POINTS( rect );    _offsetInPixels = offset;    _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels );    _originalSizeInPixels = originalSize;    _originalSize = CC_SIZE_PIXELS_TO_POINTS( _originalSizeInPixels );    _rotated = rotated;    return true;}
开发者ID:ADoby,项目名称:Project_Space_Pirate,代码行数:14,


示例6: CC_RECT_PIXELS_TO_POINTS

bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize){    _texture = nullptr;    _textureFilename = filename;    _rectInPixels = rect;    _rect = CC_RECT_PIXELS_TO_POINTS( rect );    _offsetInPixels = offset;    _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels );    _originalSizeInPixels = originalSize;    _originalSize = CC_SIZE_PIXELS_TO_POINTS( _originalSizeInPixels );    _rotated = rotated;    return true;}
开发者ID:skatpgusskat,项目名称:December,代码行数:14,


示例7: CC_RECT_PIXELS_TO_POINTS

bool CCSpriteFrame::initWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize){    m_pobTexture = NULL;    m_strTextureFilename = filename;    m_obRectInPixels = rect;    m_obRect = CC_RECT_PIXELS_TO_POINTS( rect );    m_obOffsetInPixels = offset;    m_obOffset = CC_POINT_PIXELS_TO_POINTS( m_obOffsetInPixels );    m_obOriginalSizeInPixels = originalSize;    m_obOriginalSize = CC_SIZE_PIXELS_TO_POINTS( m_obOriginalSizeInPixels );    m_bRotated = rotated;    return true;}
开发者ID:boruis,项目名称:cocos2dx-classical,代码行数:14,


示例8: CC_RECT_PIXELS_TO_POINTS

bool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize){    if (FileUtils::getInstance()->isFileExist(filename)) {        _texture = nullptr;        _textureFilename = filename;        _rectInPixels = rect;        _rect = CC_RECT_PIXELS_TO_POINTS( rect );        _offsetInPixels = offset;        _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels );        _originalSizeInPixels = originalSize;        _originalSize = CC_SIZE_PIXELS_TO_POINTS( _originalSizeInPixels );        _rotated = rotated;        _anchorPoint = Vec2(NAN, NAN);        _centerRect = Rect(NAN, NAN, NAN, NAN);        return true;    }    return false;}
开发者ID:hugohuang1111,项目名称:Bird,代码行数:18,


示例9: switch

Point TMXLayer::getPositionAt(const Point& pos){    Point ret = Point::ZERO;    switch (_layerOrientation)    {    case TMXOrientationOrtho:        ret = getPositionForOrthoAt(pos);        break;    case TMXOrientationIso:        ret = getPositionForIsoAt(pos);        break;    case TMXOrientationHex:        ret = getPositionForHexAt(pos);        break;    }    ret = CC_POINT_PIXELS_TO_POINTS( ret );    return ret;}
开发者ID:lache,项目名称:anyang,代码行数:18,


示例10: CC_SAFE_RETAIN

bool CCSpriteFrame::initWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize){    m_pobTexture = pobTexture;    if (pobTexture)    {        CC_SAFE_RETAIN(pobTexture);    }    m_obRectInPixels = rect;    m_obRect = CC_RECT_PIXELS_TO_POINTS(rect);    m_obOffsetInPixels = offset;    m_obOffset = CC_POINT_PIXELS_TO_POINTS( m_obOffsetInPixels );    m_obOriginalSizeInPixels = originalSize;    m_obOriginalSize = CC_SIZE_PIXELS_TO_POINTS( m_obOriginalSizeInPixels );    m_bRotated = rotated;    return true;}
开发者ID:boruis,项目名称:cocos2dx-classical,代码行数:19,


示例11: CCASSERT

void GuanacasteScene::campFire(){    //carga el objeto del mapa    auto Fogata = objetos->getObject("Fogata");    CCASSERT(!Fogata.empty(), "Fogata object not found");    //saco las coordenadas del objeto en el tilemap    //se hace la suma debido al error en cocos2d    float x = Fogata["x"].asFloat()+315;    float y = Fogata["y"].asFloat()+28;    //Crea el sprite y lo posiciona    SFogata = Sprite::create("Animations/CampFire.png", Rect(0, 0,64,64));    SFogata->setPosition(CC_POINT_PIXELS_TO_POINTS(Point(x,y)));    //crea la animacion de la fogata    auto animation = Animation::create();    for ( int i = 0; i < 5; ++i )    animation->addSpriteFrame(SpriteFrame::create("Animations/CampFire.png", Rect(i*64, 0,64,64)));        animation->setDelayPerUnit( 0.1333f );        auto repeatAnimation = RepeatForever::create( Animate::create(animation) );        SFogata->runAction(repeatAnimation);}
开发者ID:PadawanSofware,项目名称:Tiquicia,代码行数:20,


示例12: setOpacity

bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo){        if( tilesetInfo )    {        _texture = Director::getInstance()->getTextureCache()->addImage(tilesetInfo->_sourceImage);        _texture->retain();    }    // layerInfo    _layerName = layerInfo->_name;    _layerSize = layerInfo->_layerSize;    _tiles = layerInfo->_tiles;    _quadsDirty = true;    setOpacity( layerInfo->_opacity );    setProperties(layerInfo->getProperties());    // tilesetInfo    _tileSet = tilesetInfo;    CC_SAFE_RETAIN(_tileSet);    // mapInfo    _mapTileSize = mapInfo->getTileSize();    _layerOrientation = mapInfo->getOrientation();    // offset (after layer orientation is set);    Vec2 offset = this->calculateLayerOffset(layerInfo->_offset);    this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset));    this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(Size(_layerSize.width * _mapTileSize.width, _layerSize.height * _mapTileSize.height)));        this->tileToNodeTransform();    // shader, and other stuff    setGLProgram(GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));        _useAutomaticVertexZ = false;    _vertexZvalue = 0;    return true;}
开发者ID:keith1020,项目名称:cocos.github.io,代码行数:41,


示例13: switch

Vec2 TMXLayer::getPositionAt(const Vec2& pos){    Vec2 ret;    switch (_layerOrientation)    {    case TMXOrientationOrtho:        ret = getPositionForOrthoAt(pos);        break;    case TMXOrientationIso:        ret = getPositionForIsoAt(pos);        break;    case TMXOrientationHex:        ret = getPositionForHexAt(pos);        break;    case TMXOrientationStaggered:        ret = getPositionForStaggeredAt(pos);        break;    }    ret = CC_POINT_PIXELS_TO_POINTS( ret );    return ret;}
开发者ID:FenneX,项目名称:FenneXEmptyProject,代码行数:21,


示例14: addChild

void HelloWorld::createMapAndAddChild(){    auto map = TMXTiledMap::create("test-zorder.tmx");    addChild(map, 0, 1);        auto s = map->getContentSize();    map->setPosition(Point(-480,0));        m_testSp = Sprite::create("grossinis_sister1.png");    map->addChild(m_testSp, map->getChildren().size() );    m_testSp->retain();    int mapWidth = map->getMapSize().width * map->getTileSize().width;    m_testSp->setPosition(CC_POINT_PIXELS_TO_POINTS(Point(mapWidth/2,0)));    m_testSp->setAnchorPoint(Point(0.5f,0));        auto move = MoveBy::create(10, Point(300,250));    auto back = move->reverse();    auto seq = Sequence::create(move, back,NULL);    m_testSp->runAction( RepeatForever::create(seq) );        schedule( schedule_selector(HelloWorld::repositionSprite) );}
开发者ID:Ratel13,项目名称:book-code,代码行数:22,


示例15: addChild

//------------------------------------------------------------------//// TMXIsoZorder////------------------------------------------------------------------TMXIsoZorder::TMXIsoZorder(){    auto map = TMXTiledMap::create("TileMaps/iso-test-zorder.tmx");    addChild(map, 0, kTagTileMap);    auto s = map->getContentSize();    CCLOG("ContentSize: %f, %f", s.width,s.height);    map->setPosition(Point(-s.width/2,0));        _tamara = Sprite::create(s_pathSister1);    map->addChild(_tamara, map->getChildren().size() );    _tamara->retain();    int mapWidth = map->getMapSize().width * map->getTileSize().width;    _tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Point( mapWidth/2,0)));    _tamara->setAnchorPoint(Point(0.5f,0));        auto move = MoveBy::create(10, Point(300,250));    auto back = move->reverse();    auto seq = Sequence::create(move, back,NULL);    _tamara->runAction( RepeatForever::create(seq) );        schedule( schedule_selector(TMXIsoZorder::repositionSprite) );}
开发者ID:ioyouj,项目名称:Hello-LWF-Cocos2d-x,代码行数:29,


示例16: addChild

//------------------------------------------------------------------//// TMXIsoZorderNew////------------------------------------------------------------------TMXIsoZorderNew::TMXIsoZorderNew(){    auto map = cocos2d::experimental::TMXTiledMap::create("TileMaps/iso-test-zorder.tmx");    addChild(map, 0, kTagTileMap);    auto s = map->getContentSize();    CCLOG("ContentSize: %f, %f", s.width,s.height);    map->setPosition(Vec2(-s.width/2,0));        _tamara = Sprite::create(s_pathSister1);    map->addChild(_tamara, (int)map->getChildren().size() );    _tamara->retain();    int mapWidth = map->getMapSize().width * map->getTileSize().width;    _tamara->setPosition(CC_POINT_PIXELS_TO_POINTS(Vec2( mapWidth/2,0)));    _tamara->setAnchorPoint(Vec2(0.5f,0));        auto move = MoveBy::create(10, Vec2(300,250));    auto back = move->reverse();    auto seq = Sequence::create(move, back,nullptr);    _tamara->runAction( RepeatForever::create(seq) );        schedule( CC_SCHEDULE_SELECTOR(TMXIsoZorderNew::repositionSprite) );}
开发者ID:AnySDK,项目名称:Sample_Lua,代码行数:29,


示例17: CC_POINT_PIXELS_TO_POINTS

void CCSpriteFrame::setOffsetInPixels(const CCPoint& offsetInPixels){    m_obOffsetInPixels = offsetInPixels;    m_obOffset = CC_POINT_PIXELS_TO_POINTS( m_obOffsetInPixels );}
开发者ID:boruis,项目名称:cocos2dx-classical,代码行数:5,


示例18: cc_wcslen

void UITextArea::createFontChars(){    int nextFontPositionX = 0;    int nextFontPositionY = 0;    //unsigned short prev = -1;    int kerningAmount = 0;    CCSize tmpSize = CCSizeZero;    int longestLine = 0;    unsigned int totalHeight = 0;    unsigned int quantityOfLines = 1;	if (!m_sString) return;    unsigned int stringLen = cc_wcslen(m_sString);    if (stringLen == 0)    {        return;    }    for (unsigned int i = 0; i < stringLen - 1; ++i)    {        unsigned short c = m_sString[i];        if (c == '/n')        {            quantityOfLines++;        }    }    totalHeight = m_pConfiguration->m_nCommonHeight * quantityOfLines;    nextFontPositionY = 0-(m_pConfiguration->m_nCommonHeight - m_pConfiguration->m_nCommonHeight * quantityOfLines);    for (unsigned int i= 0; i < stringLen; i++)    {        unsigned short c = m_sString[i];        if (c == '/n')        {             nextFontPositionX = 0;            nextFontPositionY -= m_pConfiguration->m_nCommonHeight;            continue;        }        tFontDefHashElement *element = NULL;        // unichar is a short, and an int is needed on HASH_FIND_INT        unsigned int key = c;        HASH_FIND_INT(m_pConfiguration->m_pFontDefDictionary, &key, element);        CCAssert(element, "FontDefinition could not be found!");        ccBMFontDef fontDef = element->fontDef;        CCRect rect = fontDef.rect;        rect = CC_RECT_PIXELS_TO_POINTS(rect);        rect.origin.x += m_tImageOffset.x;        rect.origin.y += m_tImageOffset.y;        CCSprite *fontChar;        fontChar = (CCSprite*)(this->getChildByTag(i));        if( ! fontChar )        {            fontChar = new CCSprite();            fontChar->initWithTexture(m_pobTextureAtlas->getTexture(), rect);            this->addChild(fontChar, 0, i);            fontChar->release();        }        else        {            // reusing fonts            fontChar->setTextureRect(rect, false, rect.size);            // restore to default in case they were modified            fontChar->setVisible(true);            fontChar->setOpacity(255);        }        // See issue 1343. cast( signed short + unsigned integer ) == unsigned integer (sign is lost!)        int yOffset = m_pConfiguration->m_nCommonHeight - fontDef.yOffset;        CCPoint fontPos = ccp( (float)nextFontPositionX + fontDef.xOffset + fontDef.rect.size.width*0.5f + kerningAmount,            (float)nextFontPositionY + yOffset - rect.size.height*0.5f * CC_CONTENT_SCALE_FACTOR() );        fontChar->setPosition(CC_POINT_PIXELS_TO_POINTS(fontPos));        // update kerning        nextFontPositionX += fontDef.xAdvance + kerningAmount;        //prev = c;        // Apply label properties        fontChar->setOpacityModifyRGB(m_bIsOpacityModifyRGB);        // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on		if ( i < colors.size())		{			fontChar->setColor(colors.at(i));		}		else			fontChar->setColor(m_tColor);        // only apply opacity if it is different than 255 )        // to prevent modifying the color too (issue #610)//.........这里部分代码省略.........
开发者ID:coderHsc,项目名称:sygame,代码行数:101,


示例19: strcpy

bool TMXLayer::initWithTilesetInfo(TMXTilesetInfo *tilesetInfo, TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo){        // XXX: is 35% a good estimate ?    Size size = layerInfo->_layerSize;    float totalNumberOfTiles = size.width * size.height;    float capacity = totalNumberOfTiles * 0.35f + 1; // 35 percent is occupied ?    Texture2D *texture = nullptr;    if( tilesetInfo )    {		char tmxFilePath[FILENAME_MAX];		strcpy(tmxFilePath, mapInfo->getTMXFileName().c_str());		for (int i = strlen(tmxFilePath) - 1; i >= 0; --i)		{			if (tmxFilePath[i] == '//')			{				tmxFilePath[i] = '/0';				break;			}		}		char sourceImagePath[FILENAME_MAX];		strcpy(sourceImagePath, tmxFilePath);		strcat(sourceImagePath, "//");		strcat(sourceImagePath, tilesetInfo->_sourceImage.c_str());		texture = Director::getInstance()->getTextureCache()->addImage(sourceImagePath);    }    if (SpriteBatchNode::initWithTexture(texture, static_cast<ssize_t>(capacity)))    {        // layerInfo        _layerName = layerInfo->_name;        _layerSize = size;        _tiles = layerInfo->_tiles;        _opacity = layerInfo->_opacity;        setProperties(layerInfo->getProperties());        _contentScaleFactor = Director::getInstance()->getContentScaleFactor();         // tilesetInfo        _tileSet = tilesetInfo;        CC_SAFE_RETAIN(_tileSet);        // mapInfo        _mapTileSize = mapInfo->getTileSize();        _layerOrientation = mapInfo->getOrientation();        // offset (after layer orientation is set);        Point offset = this->calculateLayerOffset(layerInfo->_offset);        this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset));        _atlasIndexArray = ccCArrayNew(totalNumberOfTiles);        this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(Size(_layerSize.width * _mapTileSize.width, _layerSize.height * _mapTileSize.height)));        _useAutomaticVertexZ = false;        _vertexZvalue = 0;                return true;    }    return false;}
开发者ID:lache,项目名称:anyang,代码行数:62,


示例20: CC_POINT_PIXELS_TO_POINTS

void SpriteFrame::setOffsetInPixels(const Vec2& offsetInPixels){    _offsetInPixels = offsetInPixels;    _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels );}
开发者ID:hugohuang1111,项目名称:Bird,代码行数:5,


示例21: Image

bool EncryptedTMXLayer::initWithInfo(cocos2d::TMXTilesetInfo *tilesetInfo, cocos2d::TMXLayerInfo *layerInfo, cocos2d::TMXMapInfo *mapInfo, const std::string &encryptionKey){    // XXX: is 35% a good estimate ?    Size size = layerInfo->_layerSize;    float totalNumberOfTiles = size.width * size.height;    float capacity = totalNumberOfTiles * 0.35f + 1; // 35 percent is occupied ?    this->_encryptionKey = encryptionKey;    this->_encryptor = FileEncryptor::create(encryptionKey.c_str());    this->_encryptor->retain();    Texture2D *texture = nullptr;    if( tilesetInfo )    {        // decrypt first, compatible with Android        const std::string &resourcePath = FileUtils::getInstance()->fullPathForFilename(tilesetInfo->_sourceImage);        int outSize = 0;        unsigned char *data = this->_encryptor->decrypt(resourcePath, &outSize);        Image *pImage = new Image();        bool bRet = pImage->initWithImageData(data, outSize);        if (!bRet)        {            return false;        }        texture = Director::getInstance()->getTextureCache()->addImage(pImage, resourcePath);        free(data);    }    if (SpriteBatchNode::initWithTexture(texture, static_cast<ssize_t>(capacity)))    {        // layerInfo        _layerName = layerInfo->_name;        _layerSize = size;        _tiles = layerInfo->_tiles;        _opacity = layerInfo->_opacity;        setProperties(layerInfo->getProperties());        _contentScaleFactor = Director::getInstance()->getContentScaleFactor();        // tilesetInfo        _tileSet = tilesetInfo;        CC_SAFE_RETAIN(_tileSet);        // mapInfo        _mapTileSize = mapInfo->getTileSize();        _layerOrientation = mapInfo->getOrientation();        // offset (after layer orientation is set);        Point offset = this->calculateLayerOffset(layerInfo->_offset);        this->setPosition(CC_POINT_PIXELS_TO_POINTS(offset));        _atlasIndexArray = ccCArrayNew(totalNumberOfTiles);        this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(Size(_layerSize.width * _mapTileSize.width, _layerSize.height * _mapTileSize.height)));        _useAutomaticVertexZ = false;        _vertexZvalue = 0;        return true;    }    return false;}
开发者ID:quinsmpang,项目名称:Pokemon,代码行数:62,



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


C++ CC_PROFILER_START函数代码示例
C++ CC_NODE_DRAW_SETUP函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。